Geeks Talk

Prepare for your Next Interview




Query

This is a discussion on Query within the Oracle forums, part of the Databases category; Hi everyone, I'm making a query to one table and I need to get different information from one numeric field but there is not data in all records... how ...


Go Back   Geeks Talk > Databases > Oracle

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-24-2007
Junior Member
 
Join Date: Apr 2007
Location: Mexico
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jescalante is on a distinguished road
Question Query

Hi everyone, I'm making a query to one table and I need to get different information from one numeric field but there is not data in all records... how can I get a zero in the result??????
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-25-2007
Expert Member
 
Join Date: Dec 2006
Location: Chennai
Posts: 197
Thanks: 2
Thanked 16 Times in 14 Posts
Barbie is on a distinguished road
Re: Query

use decode then.
Reply With Quote
  #3 (permalink)  
Old 04-25-2007
Contributing Member
 
Join Date: Mar 2007
Posts: 43
Thanks: 1
Thanked 2 Times in 2 Posts
varmakub is on a distinguished road
Re: Query

Decode function has the functionality of an IF-THEN-ELSE statement.

The syntax for the decode function is:

decode( expression , search , result [, search , result]... [, default] )

expression is the value to compare.

search is the value that is compared against expression.

result is the value returned, if expression is equal to search.

default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).

For Example:

You could use the decode function in an SQL statement as follows:

SELECT supplier_name,
decode(supplier_id, 10000, 'DELL',
10001, 'INFOSYS',
10002, 'WIPRO',
'Gateway') result
FROM suppliers;
Reply With Quote
  #4 (permalink)  
Old 04-25-2007
Junior Member
 
Join Date: Apr 2007
Location: Mexico
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jescalante is on a distinguished road
Talking Re: Query

Thanks a lot Barbie and varmakub; the query is showing the correct information right now.
Reply With Quote
  #5 (permalink)  
Old 06-25-2007
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,432
Thanks: 8
Thanked 125 Times in 112 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: Query

simply use decode as suggested.
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Query with window XP fred Unix/Linux 1 04-03-2007 11:28 PM
Dynamic Query nancyphilips Oracle 2 10-13-2006 06:58 PM
Query with C++ StephenRaj C and C++ 1 08-14-2006 05:09 AM
Query in ASP timmy ASP.NET 1 07-26-2006 04:57 PM
Query with SQL Leading Zero timmy SQL 2 07-17-2006 05:32 PM


All times are GMT -4. The time now is 12:45 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved