I have two selects:
SELECT id FROM a -- returns 1,4,2,3
UNION
SELECT id FROM b -- returns 2,1
I’m receiving correct num of rows, like: 1,4,2,3.
But I want b table results first: 2,1,4,3 or 2,1,3,4
How can I do this?
(I’m using Oracle)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using @Adrian tips, I found a solution:
I’m using GROUP BY and COUNT.
I tried to use DISTINCT with ORDER BY but I’m getting error message: “not a SELECTed expression”
Thanks Adrian and this blog.