Home » SQL & PL/SQL » SQL & PL/SQL » order by problem
order by problem [message #235107] Fri, 04 May 2007 01:41 Go to next message
rzkhan
Messages: 345
Registered: March 2005
Senior Member
my query

  1  select b.member_id,rpad(i.item,20) as item,b.amount,b.m,b.y
  2  from bill b, items i
  3  where b.item_id=i.item_id
  4  and b.member_id=1
  5* order by 1
SQL> /

MEMBER_ ITEM                     AMOUNT M            Y
------- -------------------- ---------- --- ----------
1       LUNCH/DINNER                 40 MAR       2007
1       BREAKFAST                    30 MAR       2007
1       ELECTRICITY                   0 MAR       2007
1       MESSING                  364.21 MAR       2007
1       GAS                       12.96 MAR       2007
1       COLD DRINKS                  10 MAR       2007

6 rows selected.


How can I sort the output so that the item MESSING comes at top.

Plz help
riaz
Re: order by problem [message #235109 is a reply to message #235107] Fri, 04 May 2007 01:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
order by 1, decode(item,'MESSING',CHR(0),item)

Regards
Michel
Re: order by problem [message #235111 is a reply to message #235109] Fri, 04 May 2007 01:55 Go to previous messageGo to next message
rzkhan
Messages: 345
Registered: March 2005
Senior Member
Thank you,

Riaz
Re: order by problem [message #235239 is a reply to message #235111] Fri, 04 May 2007 07:51 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
or
order by 2 desc

or
order by 3 desc


both will work with your data.

What is your purpose of the rpad in this query?

[Updated on: Fri, 04 May 2007 07:52]

Report message to a moderator

Re: order by problem [message #235496 is a reply to message #235107] Sun, 06 May 2007 22:27 Go to previous messageGo to next message
rzkhan
Messages: 345
Registered: March 2005
Senior Member
I am using rpad to decrease the column display length.

is this ok? or I should use substr ?
Re: order by problem [message #235504 is a reply to message #235496] Sun, 06 May 2007 23:56 Go to previous messageGo to next message
ab_trivedi
Messages: 460
Registered: August 2006
Location: Pune, India
Senior Member
substr.
Re: order by problem [message #235505 is a reply to message #235504] Sun, 06 May 2007 23:59 Go to previous message
rzkhan
Messages: 345
Registered: March 2005
Senior Member
ok
thank you
Previous Topic: Hi Experts,
Next Topic: ORA-12801 [SOLVED]
Goto Forum:
  


Current Time: Sat Dec 03 01:32:23 CST 2016

Total time taken to generate the page: 0.27800 seconds