Skip to content
Advertisement

configure query to bring rows which have more than 1 entries

How to get those entries which have more than 1 records?

If it doesn’t make sense… let me explain:

From the below table I want to access the sum of the commission of all rows where type is joining and “they have more than 1 entry with same downmem_id“.

I have this query but it doesn’t consider more entries scenario…

Here’s the table:

Here’s the expected result: it should be the sum of the id no 2, 7 only ie. 3250+353=whatever.

It shouldn’t include id no 6 because it has only 1 row with the same downmem_id.

Please help me to make this query.

Advertisement

Answer

Another approach is two levels of aggregation:

The main advantage to this approach is that this more readily supports more complex conditions on the other members of each group — such as at most one “joining” record or both “joining” records and no more than two “vnsjkdv” records.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement