Home » Developer & Programmer » Reports & Discoverer » Pls. help. Why have no output. (order by)
Pls. help. Why have no output. (order by) [message #333221] Thu, 10 July 2008 21:40 Go to next message
hareluya_17
Messages: 2
Registered: July 2008
Location: Bangkok, Thailand
Junior Member
I want to show top ten and order by SPT_BCCY desc.
I use asc ,that show ascending order.

SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT,
SHAPE_DESC, COLOR, SPT_BCCY
FROM (SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT,
SHAPE_DESC, COLOR, SPT_BCCY FROM V_TXN_LIST
ORDER BY SPT_BCCY asc)
WHERE ROWNUM <= 10;

result
Item_code...Item_des...Category... Cut...Shape_desc...Color ...Spt_bccy
xxxx..............xxxx............xxxx ..........xx......xxxx................xx ........5.5
xxxx..............xxxx............xxxx ..........xx......xxxx................xx ........11
xxxx..............xxxx............xxxx ..........xx......xxxx................xx ........13
xxxx..............xxxx............xxxx ..........xx......xxxx................xx ........16
xxxx..............xxxx............xxxx ..........xx......xxxx................xx ........22
......

But I use descending order. It's not show anything.
If I don't use rownum, it's show descending order
but show in other page.

SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT,
SHAPE_DESC, COLOR, SPT_BCCY
FROM (SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT,
SHAPE_DESC, COLOR, SPT_BCCY FROM V_TXN_LIST
ORDER BY SPT_BCCY desc)
WHERE ROWNUM <= 10;

result
Item_code...Item_des...Category... Cut...Shape_desc...Color ...Spt_bccy
xxxx..............xxxx............xxxx ..........xx......xxxx................xx
xxxx..............xxxx............xxxx ..........xx......xxxx................xx
xxxx..............xxxx............xxxx ..........xx......xxxx................xx
xxxx..............xxxx............xxxx ..........xx......xxxx................xx
xxxx..............xxxx............xxxx ..........xx......xxxx................xx

Why it's not show in first page same as asc order.
Please help me.
Re: Pls. help. Why have no output. (order by) [message #333584 is a reply to message #333221] Sun, 13 July 2008 05:04 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
In your first query, you are selecting top 10 (first 10) after doing ascending order.
In your second query, you are selecting top 10 (last 10) after doing descending order. As NULL is being treated as max value, NULL values are coming as the top 10 records...

What exactly you want to show?
Do you want to show the top 10 (first 10) in descending order?
Try this.
SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT
      ,SHAPE_DESC, COLOR, SPT_BCCY
  FROM (SELECT ITEM_CODE, ITEM_DESCRIPTION, CATEGORY, CUT
              ,SHAPE_DESC, COLOR, SPT_BCCY 
          FROM V_TXN_LIST
         ORDER BY SPT_BCCY asc)
 WHERE ROWNUM <= 10
 ORDER BY SPT_BCCY desc;
By
Vamsi
Re: Pls. help. Why have no output. (order by) [message #333634 is a reply to message #333221] Sun, 13 July 2008 21:09 Go to previous message
hareluya_17
Messages: 2
Registered: July 2008
Location: Bangkok, Thailand
Junior Member
Oh, Thank you very much.

^______^
Previous Topic: displaying header with datbase value
Next Topic: Thousand Seprator In XML
Goto Forum:
  


Current Time: Sat Nov 30 05:56:16 CST 2024