Link to home
Start Free TrialLog in
Avatar of paulca
paulca

asked on

Order By Clause

Here is the table structure:

*****************************************
* ID     DOC_ID       NAME          VALUE     *
*****************************************
  1       101      SIZE                6
  2       102      SIZE                2
  3       103      SIZE                5
  4       104      SIZE                2
  5       101      SHEET           2
  6       102      SHEET           3
  7       103      SHEET           4
  8       104      SHEET           34
----------------------------------------------------

Is there a way to ORDER on SIZE so that the VALUE would be returned as 1, 5, 6?  Thanks.
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

select * from yourtable
  where name = 'SIZE'
  order by value

This will do the trick.

Good Luck,
Steve
Avatar of dhanush
dhanush

what do you mean 1,5,6? Is it ID or value? Do you want the values for name having "SIZE" only?
I looked at the data incorrectly. I don't see any VALUE equal to 1 where the name is equal to SIZE. I'm guessing you meant 2, 5, 6. Also, since there are multiple 2's I'll assume you want only one 2.

select distinct id, name, value from yourtable
  where name = "SIZE"
  order by id, value
ASKER CERTIFIED SOLUTION
Avatar of winningl
winningl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial