Multiple whereClause in codeless

Hello
I have a table called UserWorkouts that has amongst others, the following columns;

workout
ownerId
distance

I am trying to create a ‘Leaderboard’ using an API. What I want to pull from this table, is the best result (i.e. greatest distance) for each type of workout (say A, B, or C) for each user (i.e. ownerId). And then sort them by greatest distance to smallest.
I have previously used a service to get around pagination (to bring back +100 records), so I am trying to adapt that method but not having much joy.

My questions;
In my method, am I able to have multiple whereClauses? I cannot figure out how to put multiple clauses into codeless (I have created them but cannot wedge them in!?!??!)
Also, in terms of sorting by distance (that is easy) but how would I go about only bringing back 1 record per ownerId? I am assuming if I sort by distance and then remove ‘duplicates’, I will be left with the greatest distance record…not sure if that is possible in codeless?

Thanks
Paul

Hi, @Paul_McCullen

According to your first question:

In my method, am I able to have multiple whereClauses? I cannot figure out how to put multiple clauses into codeless (I have created them but cannot wedge them in!?!??!)

Where Clause can be only one, you need to put all queries on one line using OR/AND
for example: name is 'Test' AND age > 12 OR age = 15

Also, in terms of sorting by distance (that is easy) but how would I go about only bringing back 1 record per ownerId? I am assuming if I sort by distance and then remove ‘duplicates’, I will be left with the greatest distance record…not sure if that is possible in codeless?

As for the second case, we are looking into it and will back to you as soon as got some result.

Regards,
Marina

Thanks Marina.

Can you explain how to put them on one line in codeless? I need to use a service for pagination, so I need to build this in codeless…but cannot figure it out…

Thanks
Paul

Assuming you have individual conditions A, B and C, you can group them using “and” and “or” operators to create one where clause:

(A and B) or C
A or B or C
etc…

Hope this helps.

Regards,
Mark

1 Like