If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Simple, must be simple :)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-05, 07:27
Peterpeter Peterpeter is offline
Registered User
 
Join Date: Oct 2005
Posts: 3
Post Simple, must be simple :)

Need for help

simple query

select docsum, agent
from tb1

so far so good
but now is need for one more column (the third one), where docsum >500
Please, any suggestions
Reply With Quote
  #2 (permalink)  
Old 10-26-05, 10:32
madafaka madafaka is offline
Registered User
 
Join Date: Feb 2004
Location: Dublin, Ireland
Posts: 212
specify clearly what you need:

1) Select just rows where docsum > 500

2) Select all rows but display docsum only for these rows where docsum > 500?

In first case use:
Code:
select docsum, agent
from tb1
where docsum > 500
In second case, you can use more options depends on database server e.g. on oracle:

Code:
select 
case when docsum <= 500 then
 null
else
 docsum
end docsum,
agent
from tb1
Reply With Quote
  #3 (permalink)  
Old 10-27-05, 03:57
Peterpeter Peterpeter is offline
Registered User
 
Join Date: Oct 2005
Posts: 3
Thank`s madafaka, the second case i was looking for
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On