RE: If else statement

RE: If else statement

 

  

SELECT
SUM(CASE WHEN sal BETWEEN 800 AND 1100 THEN 1 ELSE 0 END) AS "800-1100",
SUM(CASE WHEN sal BETWEEN 1250 AND 1600 THEN 1 ELSE 0 END) AS
"1250-1600",
SUM(CASE WHEN sal BETWEEN 2450 AND 2975 THEN 1 ELSE 0 END) AS
"2450-2475",
SUM(CASE WHEN sal BETWEEN 3000 AND 5000 THEN 1 ELSE 0 END) AS
"3000-5000"
FROM emp
/





Please take a few minutes to provide feedback on the quality of service you received from our staff. The Department of Education values your feedback as a customer. Commissioner of Education Jeanine Blomberg is committed to continuously assessing and improving the level and quality of services provided to you.Simply use the link below. Thank you in advance for completing the survey.


http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]




-----Original Message-----
From: Edwards, Ed
Sent: Wednesday, August 08, 2007 6:20 AM
To: 'Jyoti Chawla '; LazyDBA Discussion
Subject: RE: If else statement
Importance: High

-- Suppose you want to find the average salary of all employees in the
company.
-- If an employee's salary is less than $2,000, then use

SELECT
AVG(CASE WHEN sal > 2000 THEN sal ELSE 2000 END) AS
"AVG_SAL_IN_2000_RANGE"
FROM emp
/

-----Original Message-----
From: Jyoti Chawla
[mailto:oracledba-ezmlmshield-x83745932.[Email address protected]
Sent: Wednesday, August 08, 2007 6:11 AM
To: LazyDBA Discussion
Subject: If else statement


Hi All,

Can we add if else condition in a select query?

Thanks,
Jyoti


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
solely for the use of the addressee(s). If you are not the intended
recipient, please notify the sender by e-mail and delete the original
message. Further, you are not to copy, disclose, or distribute this
e-mail or its contents to any other person and any such actions are
unlawful. This e-mail may contain viruses. Infosys has taken every
reasonable precaution to minimize this risk, but is not liable for any
damage you may sustain as a result of any virus in this e-mail. You
should carry out your own virus checks before opening the e-mail or
attachment. Infosys reserves the right to monitor and review the content
of all messages sent to or from this e-mail address. Messages sent to or
from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***


---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html

Oracle LazyDBA home page