79675657

Date: 2025-06-23 05:26:26
Score: 0.5
Natty:
Report link

The query that you tried seems to show that you have the intuition that group by will help you, but misuse it in the details.

Grouping will effectively help you to generate one output rows from multiple rows fetched from the joins.

Before grouping you should ask yourself what reality each row represents, and what columns are duplicates regarding your problem: they are the ones you will group on.

For example, with the following data (intermediate results of an hypothetical join on the database of an hypothetical clothes seller):

customer_id first_name last_name order_id quantity what
1 John Smith 1000 1 trousers
1 John Smith 1001 1 sock
1 John Smith 1002 1 sock
2 Jane Smith 1003 2 sock
3 John Smith 1004 1 trousers

You can choose to group by against two different axes, depending on what you're interested in:

The problem I see in your query is that you group by (nearly) every field you encounter so probably you first have to question yourself about what reality do I want a unique row for in my end result?

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-1):
Posted by: Guillaume Outters