Home » SQL & PL/SQL » SQL & PL/SQL » order by
order by [message #209095] Wed, 13 December 2006 05:23 Go to next message
brihaspatirai
Messages: 24
Registered: November 2006
Location: pune
Junior Member
i want to use order by asc but null should come in first.
my query is

SELECT CORPORATION_MST.CORPORATION_CODE ,
CORPORATION_MST.CORP_DESCRIPTION ,
CORPORATION_LINES_MST.LINE_CODE ,
LINES_MST.LINE_DESCRIPTION ,
CORPORATION_LINES_MST.TOTAL_LINE_AMNT ,
CORPORATION_LINES_MST.UTILIZED_LINE_AMNT ,
CORPORATION_MST.CUSTOMER_CODE ,
LINES_MST.LINE_TENOR
FROM
CORPORATION_LINES_MST ,
CORPORATION_MST ,LINES_MST
WHERE
(CORPORATION_MST.CORPORATION_CODE =CORPORATION_LINES_MST.CORPORATION_CODE)
and(LINES_MST.LINE_CODE=CORPORATION_LINES_MST.LINE_CODE)

order by customer_code nulls first , line_tenor

i've to use it on customer_code but doing like above i'm not getting proper result

plz help me

[Updated on: Wed, 13 December 2006 05:40]

Report message to a moderator

Re: order by [message #209096 is a reply to message #209095] Wed, 13 December 2006 05:25 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Use:

order by <column_name> nulls first;
Re: order by [message #209118 is a reply to message #209096] Wed, 13 December 2006 06:54 Go to previous messageGo to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
ebrian is nulls first a new concept in 10 g?
Re: order by [message #209126 is a reply to message #209118] Wed, 13 December 2006 07:17 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
No. It's been there since at least 8i.
Re: order by [message #209136 is a reply to message #209095] Wed, 13 December 2006 08:05 Go to previous message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
See example below:

SQL> select * from test1;

	X1	Y1
---------- -------
      1000	 1
      2000	 1
      1000	 2
      9999

SQL> select * from test2;

	X2	Y2
---------- -------
      1000	 1
      2000	 1
      9999	 1

SQL> select test1.x1, test1.y1
  2	from test1, test2
  3	where test1.x1 = test2.x2
  4	order by y1, x1;

	X1	Y1
---------- -------
      1000	 1
      2000	 1
      1000	 2
      9999

SQL> select test1.x1, test1.y1
  2	from test1, test2
  3	where test1.x1 = test2.x2
  4	order by y1 nulls first, x1;

	X1	Y1
---------- -------
      9999
      1000	 1
      2000	 1
      1000	 2
Previous Topic: Substitue characters in field
Next Topic: Can't write my SQL recursive request (Oracle 10)
Goto Forum:
  


Current Time: Tue Dec 06 10:16:16 CST 2016

Total time taken to generate the page: 0.07589 seconds