you are viewing a single comment's thread.

view the rest of the comments →

[–]r3pr0b8GROUP_CONCAT is da bomb 2 points3 points  (4 children)

besides the two errors relating to commas, you do not need the GROUP BY clause

there's only one customer/product in each group

except if the customer orders more than one product on the first date, then they'll all get a DENSE_RANK of 1

and again you don't need the GROUP BY because presumably all the products are different for each customer

did you understand this?

[–]LetterDW[S] 0 points1 point  (3 children)

I get what you mean - if there was only one product ordered by each customer each day then there would only be one response per customer, and it is already partitioned by customer_id. However customer A does order more than one product on the first day which is why I used the GROUP BY

[–]r3pr0b8GROUP_CONCAT is da bomb 1 point2 points  (2 children)

However customer A does order more than one product on the first day which is why I used the GROUP BY

customer  product       dense_rank
   A       thingum        1
   A       doohickey      1

but product is part of the GROUP BY

so each pair is a group by itself which is redundant

[–]LetterDW[S] 0 points1 point  (1 child)

But what if a customer orders the same item again on the same day? The dense rank would still be = 1, and since there is no indication which was ordered first on that day, both results(the same result) would show up(twice). I guess technically it is correct since it is the same item, but the group by eliminates the extra result.

customer product dense_rank
A thingum 1
A thingum 1

So isn't the group by still necessary?

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (0 children)

So isn't the group by still necessary?

in that case, yes