Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

performing an order by, and ignoring certain values.

Status
Not open for further replies.

tekkerguy

Programmer
Nov 16, 2005
196
US
is there anyway to do an order by in sql, but ignoring certain values?


For example, order by "moneyinpocket"

But if a value is null, "ND", or 0, ignore them.
 
Tekker,

How about:
Code:
...order by nvl(moneyinpocket,0)...
...which says, "IF moneyinpocket IS NULL, THEN use '0' as the value of that tuple, otherwise use the value of moneyinpocket."

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Hi,
But that would not handle the examples:
"ND" or 0

Would a Decode maybe work here?

Order by decode(moneyinpocket,NULL,' ','ND',' ',0,' ',moneyinpocket)





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Good catch, Turk, I apparently read only what I wanted to read. [banghead]. Yours is a better solution given the specifications.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Hi,
Its rare that you miss anything....[shocked]





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top