MySQL Forums
Forum List  »  Newbie

Re: Select all the rows that fulfill the criteria: only the first 2 occurences of a value in column B
Posted by: Cristian Tanasa
Date: April 26, 2021 11:56PM

Yes, I mean HAVING COUNT(Cust).

I don't think that I have the privileges to run Show Create Table.

A colleague helped me with a working statement in Oracle:

SELECT * from
(SELECT a.* , ROW_NUMBER() over (PARTITION BY Cust. ORDER BY OrderID desc) RANK
FROM Table a)
WHERE RANK IN (1,2);

It just doesn't work in MySQL, where I need it.
Any ideas?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.