Outline ·
[ Standard ] ·
Linear+
Oracle select statement
|
TSlonewolf
|
Feb 23 2006, 03:20 PM, updated 20y ago
|
|
SELECT * FROM PRODUCT WHERE ROWNUM< 50 ORDER BY CREATED DESC
minus
SELECT * FROM PRODUCT WHERE ROWNUM< 20 ORDER BY CREATED DESC
is to have error....am i suppost to do a sub select?
This post has been edited by lonewolf: Feb 23 2006, 03:20 PM
|
|
|
|
|
|
nxfx
|
Feb 23 2006, 03:51 PM
|
|
and the error is..?? and what exactly you want to achieve?
|
|
|
|
|
|
rukawa
|
Feb 23 2006, 08:02 PM
|
|
I think he wants to subtract from a result from one query from another query though I don't quite understand whether is it really.
This question is too vague.
This post has been edited by rukawa: Feb 23 2006, 08:03 PM
|
|
|
|
|
|
Marcus
|
Feb 23 2006, 11:48 PM
|
Getting Started

|
It looks like you wanna extract data between rownum 20 to 49, rite? In a more simpler manner, i think the query should be like : SELECT * FROM PRODUCT WHERE ROWNUM BETWEEN 20 AND 49 ORDER BY CREATED DESC; Try this and see. I don't think a sub-query is necessary. This post has been edited by Marcus: Feb 24 2006, 12:01 AM
|
|
|
|
|
|
TSlonewolf
|
Feb 24 2006, 02:15 PM
|
|
QUOTE(Marcus @ Feb 23 2006, 11:48 PM) It looks like you wanna extract data between rownum 20 to 49, rite? In a more simpler manner, i think the query should be like : SELECT * FROM PRODUCT WHERE ROWNUM BETWEEN 20 AND 49 ORDER BY CREATED DESC; Try this and see. I don't think a sub-query is necessary.  haha..that doesn work... anyway i found the solution..is slightly more complex here is the answer select * from ( select p.*,rownum row_num from ( select * from PRODUCT order by DATE desc ) p ) where row_num between 20 and 50
|
|
|
|
|
|
fly
|
Feb 24 2006, 02:43 PM
|
¯\(°_o)/¯
|
QUOTE(lonewolf @ Feb 24 2006, 02:15 PM) haha..that doesn work... anyway i found the solution..is slightly more complex here is the answer select * from ( select p.*,rownum row_num from ( select * from PRODUCT order by DATE desc ) p ) where row_num between 20 and 50 That seems overly complicated to me. Why not use: CODE select * from ( select p.*,rownum row_num from PRODUCT where row_num < 50 order by DATE desc ) where row_num > 20 You can cut out one nested statement this way.
|
|
|
|
|
|
anthony_yio
|
Feb 24 2006, 07:07 PM
|
........
|
QUOTE(fly @ Feb 24 2006, 02:43 PM) That seems overly complicated to me. Why not use: CODE select * from ( select p.*,rownum row_num from PRODUCT where row_num < 50 order by DATE desc ) where row_num > 20 You can cut out one nested statement this way. Ok, some beautification on you guys codes. Why not place all your SELECT* ,,, as VIEWS and call those VIEWS. It hurts my eyes when I see all those SELECT here and there. (nested)
|
|
|
|
|
|
fly
|
Feb 24 2006, 07:24 PM
|
¯\(°_o)/¯
|
QUOTE(anthony_yio @ Feb 24 2006, 07:07 PM) Ok, some beautification on you guys codes. Why not place all your SELECT* ,,, as VIEWS and call those VIEWS. It hurts my eyes when I see all those SELECT here and there. (nested) Because he may not have permission to create views in the database?
|
|
|
|
|