Home » RDBMS Server » Server Administration » GROUP BY & ROWNUM
GROUP BY & ROWNUM [message #374929] Thu, 12 July 2001 05:26 Go to next message
Pavel Aksonov
Messages: 4
Registered: July 2001
Junior Member
I wonder that query "select * from tab group by id rownum<=500" which contains more than 500 records show only 117 records. I think it's because of "GROUP BY" statement. How I can limit to exact 500 records my output? Please help.
Re: GROUP BY & ROWNUM [message #374932 is a reply to message #374929] Thu, 12 July 2001 06:01 Go to previous messageGo to next message
Pavel Aksonov
Messages: 4
Registered: July 2001
Junior Member
Yes! select * from (select * from tab group by id) where rownum<=500. It's works!
Re: GROUP BY & ROWNUM [message #374950 is a reply to message #374929] Fri, 13 July 2001 09:06 Go to previous messageGo to next message
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
Rownum would work properly when you dont use = operator in the query. Try the same with ROWNUM<501 then it should give your desired result, I guess. As per my experience, the ROWNUM does not work properly when it is given with = or BETWEEN operator.
Try it out. Hope it works for you.
Re: GROUP BY & ROWNUM [message #374951 is a reply to message #374929] Fri, 13 July 2001 09:08 Go to previous message
Sudhakar Atmakuru
Messages: 58
Registered: May 2001
Member
Rownum would work properly when you dont use = operator in the query. Try the same with ROWNUM<501 then it should give your desired result, I guess. As per my experience, the ROWNUM does not work properly when it is given with = or BETWEEN operator.
Try it out. Hope it works for you.
Previous Topic: How to avoid replication of rows while making the joins between two tables?
Next Topic: Re: "order by rand" how can I do the same ?
Goto Forum:
  


Current Time: Sun Jul 07 16:36:16 CDT 2024