Home » SQL & PL/SQL » SQL & PL/SQL » order by
order by [message #587553] Mon, 17 June 2013 01:01 Go to next message
lavkumar78
Messages: 9
Registered: June 2013
Location: delhi
Junior Member

hello Expert

plase help me

I am one table create tt1(A varchar2(6),B number(5));

insert data in this column

tt1
A B
---------------
F1 1
F365 2
F10 3
F65 4
F55 5


Q. how to get order by a column
i wan't to
tt1
A
--------------------
F1
F10
F35
F65
F365

Q. how to get order by a column
i wan't to
tt1
A
--------------------
F0001
F0010
F0035
F0065
F0365
Re: order by [message #587556 is a reply to message #587553] Mon, 17 June 2013 01:19 Go to previous messageGo to next message
Littlefoot
Messages: 21826
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
A1: Order by regular expression that looks only at the numeric part of the string
A2: Order by LPAD (with zeros up to 4 characters in length) numeric part of the string
Re: order by [message #587559 is a reply to message #587553] Mon, 17 June 2013 01:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68770
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Welcome to the forum.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Regards
Michel
Re: order by [message #587562 is a reply to message #587556] Mon, 17 June 2013 01:38 Go to previous messageGo to next message
lavkumar78
Messages: 9
Registered: June 2013
Location: delhi
Junior Member

dear friend


I am try please
but no correct result.........
Re: order by [message #587565 is a reply to message #587562] Mon, 17 June 2013 01:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68770
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Post hat you have tried (following the link I gave).

Regards
Michel
Re: order by [message #587566 is a reply to message #587562] Mon, 17 June 2013 01:43 Go to previous messageGo to next message
John Watson
Messages: 8989
Registered: January 2010
Location: Global Village
Senior Member
What did you try, and what was the result? You will not get an answer unless you show that you have made an effort yourself.
Re: order by [message #587593 is a reply to message #587566] Mon, 17 June 2013 05:40 Go to previous messageGo to next message
lavkumar78
Messages: 9
Registered: June 2013
Location: delhi
Junior Member

insert data in this column

tt1
A B
---------------
F1 1
F365 2
F10 3
F65 4
F55 5


Q. how to get order by a column
i wan't to
tt1
A
--------------------
F1
F10
F35
F65
F365

Q. how to get order by a column
i wan't to
tt1
A
--------------------
F0001
F0010
F0035
F0065
F0365


i am try to dis query...
Re: order by [message #587595 is a reply to message #587593] Mon, 17 June 2013 05:45 Go to previous messageGo to next message
Michel Cadot
Messages: 68770
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Michel Cadot wrote on Mon, 17 June 2013 08:33
Welcome to the forum.

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.


John Watson wrote on Mon, 17 June 2013 08:43
What did you try, and what was the result? You will not get an answer unless you show that you have made an effort yourself.


Regards
Michel

[Updated on: Mon, 17 June 2013 05:45]

Report message to a moderator

Re: order by [message #587596 is a reply to message #587595] Mon, 17 June 2013 05:52 Go to previous messageGo to next message
kanoujiapraveen
Messages: 1
Registered: June 2013
Location: Mumbai, INDIA
Junior Member
Hi Luv ,

Check below query, It should work Smile
select * from tt1 order by lpad ( substr ( A, 2 ) ,0,4 ) ;
Re: order by [message #587597 is a reply to message #587596] Mon, 17 June 2013 06:03 Go to previous messageGo to next message
Littlefoot
Messages: 21826
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, maybe it should, but it does not.

Did you test it?
Re: order by [message #587598 is a reply to message #587596] Mon, 17 June 2013 06:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68770
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
kanoujiapraveen wrote on Mon, 17 June 2013 12:52
Hi Luv ,

Check below query, It should work Smile
select * from tt1 order by lpad ( substr ( A, 2 ) ,0,4 ) ;


Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.
Also always post your Oracle version, with 4 decimals.

I'd add you start in this forum by answering (or trying to answer) to someone that is reluctant to follow this forum rules is not a good point for you.
Do you think we are unable to answer? If we don't then there may be a reason, as a new comer, don't go against it.

Regards
Michel
Re: order by [message #587622 is a reply to message #587598] Mon, 17 June 2013 08:18 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
If the column always starts with a single alpha column and the rest is number then

order by to_number(substr(a,2))
Re: order by [message #587664 is a reply to message #587596] Mon, 17 June 2013 21:53 Go to previous messageGo to next message
lavkumar78
Messages: 9
Registered: June 2013
Location: delhi
Junior Member

hello kanoujiapraveen

your query not correct.......
Re: order by [message #587666 is a reply to message #587664] Mon, 17 June 2013 22:18 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
With free advice, you sometime get what you paid for it.
Previous Topic: enhancing performance of join
Next Topic: sending arabic sms to gsm from oracle database
Goto Forum:
  


Current Time: Thu Sep 04 08:46:21 CDT 2025