Home » SQL & PL/SQL » SQL & PL/SQL » Error in Order By SQL STMT
Error in Order By SQL STMT [message #233661] Fri, 27 April 2007 02:10 Go to next message
prathimaprasunrao
Messages: 6
Registered: April 2007
Junior Member
hello everyone,
I have a table with the following information:

slope code item
2 10-15%
3 15-25%
4 25-50%
5 2-6%
6 6-10%
7 greater than 50%
1 0-2%
I want the order of "item" to be as follows:
0-2%
2-6%
6-10%
10-15%
15-25%
25-50%
Greater than 50%

For that I have written the following query:
select item, slope code from tname order by item asc;
I got the following output:
item slopecode
0-2% 1
10-15% 2
15-30% 3
2-6% 5
25-50% 4
6-10% 6
greaterthan50% 7


I have another table with the following information:
code item
2 Inform
3 observation
4 Subsurface
5 surface
1 historic
6 9999(default value)
So I inserted new item value"metal".This new value displayed in the list box.
7 metal
But I want the order of "items" in the list box to be displayed in the follwoing manner:
Historic
Inform
Metal
Observation
Subsurface
surface

For that I have written the query:
select item, code from tname order by item asc.
but the result of this shows "metal" as the last element in the list box.
Could anyone let me know whats wrong in my sql statement?
Waiting for reply ASAP.
Thanks,
Prathima
Re: Error in Order By SQL STMT [message #233663 is a reply to message #233661] Fri, 27 April 2007 02:16 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1/ order by slope
2/ order by item should work, I don't see how "metal" can be the last element if you order as you said.

Regards
Michel

[Updated on: Fri, 27 April 2007 02:17]

Report message to a moderator

Re: Error in Order By SQL STMT [message #233678 is a reply to message #233661] Fri, 27 April 2007 02:56 Go to previous messageGo to next message
prathimaprasunrao
Messages: 6
Registered: April 2007
Junior Member
i wrote the following query:
select item from tname order by item asc;
it displayed values in the following order:
Historic
Inform
Metal
Observation
subsurface
surface.
this is the order which i wanted.
then at the sql prompt,
sql>commit;
it displayed "Commit Complee".
I refreshed the form where i wanted to see this result but I couldn't find this output in the list box i.e., metal still remains the last value in the list box.

Waiting for reply!.

Re: Error in Order By SQL STMT [message #233680 is a reply to message #233678] Fri, 27 April 2007 03:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Which list box? There is no list box in my SQL*Plus.

Regards
Michel
Re: Error in Order By SQL STMT [message #233681 is a reply to message #233678] Fri, 27 April 2007 03:04 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
It seems you are confusing two things here.
You execute a query and commit in sqlplus, but you are talking about a list-box. (Oracle Forms??)
You should change the query that is used to fill that listbox. In other words: change the code of you application. (your Oracle Form?)

[Updated on: Fri, 27 April 2007 03:04]

Report message to a moderator

Re: Error in Order By SQL STMT [message #233694 is a reply to message #233661] Fri, 27 April 2007 03:20 Go to previous messageGo to next message
prathimaprasunrao
Messages: 6
Registered: April 2007
Junior Member
list box corresponds to a form that's written in jsp.
when i make changes to the tables, i can see the effect in the form
Re: Error in Order By SQL STMT [message #233713 is a reply to message #233694] Fri, 27 April 2007 04:01 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Then change the query in the jsp (or the DAO generating the data for the jsp)
Previous Topic: Updating dynamically depending on values
Next Topic: Very Good Doubt in PL/SQL
Goto Forum:
  


Current Time: Sat Dec 03 07:54:26 CST 2016

Total time taken to generate the page: 0.15077 seconds