Kami Sli
Kami Sli

Reputation: 1

MySQL group by for row_number

I have the compilation of all possible scenarios available to me in a SQL view. I need to get the position based on the 3 parameters: attr_1, attr_2, attr_3 considering the date as to order by. A customer is given attr_1 can make 3 choices considering both attributes 2 and 3, the date of the decision is saved in date attribute, what is later taken into account of the position on the list. Fist registered get the top position.

sample of raw data

1

I'm using the query below

select attr_1, attr_2, attr_3, date, ID , row_number() over (ORDER BY attr_2 ASC) AS POSITION FROM Table

I was able to add a counter that way, what I need is to also group the results by the three parameters, so if a customer makes the three choices they will be given the position from the group of people making the same choice.

Upvotes: 0

Views: 23

Answers (0)

Related Questions