GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 196 of 203    Print  
SELECT Statement in CASE
How to use select statement in Case?


  
Total Answers and Comments: 2 Last Update: June 24, 2009     Asked by: Savindra.Bandi 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 03, 2009 12:33:50   #1  
sunraajkumar Member Since: June 2008   Contribution: 7    

RE: SELECT Statement in CASE
Example sample query: if then else condition

SELECT empno ename
job sal

CASE job WHEN 'manager' THEN sal *0.10

WHEN 'analyst' THEN sal *0.20

WHEN 'president' THEN sal *0.30

ELSE sal END "Revised Salary" from emp;

 
Is this answer useful? Yes | No
June 24, 2009 02:25:13   #2  
sen_sam86 Member Since: June 2008   Contribution: 10    

RE: SELECT Statement in CASE
SELECT e.emp_name e.emp_id

CASE e.emp_id
WHEN 1133 THEN ' The new name is ' || e.emp_name
WHEN 1134 THEN ' The new name is ' || e.emp_name
END AS "New_emp_name"

FROM emp e

hope this will help u !

 
Is this answer useful? Yes | No

 Related Questions

Can we use aggregate function in another aggregate functionsuppose we got count of a column by using the group by clause so we get different counts in the same statement how to get the maximum of count
Read Answers (11) | Asked by : sahithi

Latest Answer : We cannot use a commit statement in a trigger. Trigger has auto commit. ...
Read Answers (18) | Asked by : suresh

In SQL. (DB2)there is one Dept table and other Emp tableQuestion- select Emp Name from Emp whose Dept No. is not in Dept table and it is present in Emp table Plz tell the Query?
Read Answers (8) | Asked by : dinesh

Hey there SQL MASTERS, here are some questions i was posed in an interview/assessment thing, dunno how well i did....Coud u answer these questions? i dont know how easy/difficut they are for u, all i know is that i had SERIOUS trouble with them! thanks alot!EMPLOYEEEmployee_id number NOT NULL (Primary Key)Employee_name VarChar(30) NOT NULL Dept_id number NOT NULL (Foreign Key to DEPARTMENT)Manager_id number NOT NULL (Foreign Key to EMPLOYMENT)Salary number
Read Answers (7) | Asked by : zen

Select 1 from dualunionselect 'A' from dual; I guess the query will select zero rows. Is it wrong or right ? if wrong thenWhat will be the result set for the query?Thanks in advance.
Read Answers (4) | Asked by : Rachana

Having following table named RATING :EmpID,ReviewSeason,CustID1,s1,c11,s1,c21,s2,c32,s2,c22,s3,c43,s3,c5Write a SQL statement, return EmpID who has been REVIEWED more than once.
Read Answers (3) | Asked by : zanhsieh

Giving two tables:EmpCustEmpName, CustID, EmpIDApril, 1, AApril, 3, AApril, 2, ABruce, 4, BBruce, 5, BCarson, 2, CCarson, 1, CCarson, 3, CDavid, 2, DCustReviewCustID, ReviewDate, EmpID1, 01-05-06, A1, 12-13-05, C2, 07-04-04, A2, 05-21-03, C2, 04-02-03, D3, 10-10-02, A3, 02-01-06, C4, 01-01-06, B5, 12-12-04, BWrite a SQL statement that return each EmpName and LATEST ReviewDate. Result should look like this:EmpName, ReviewDateApril, 01-05-06Bruce, 01-01-06...
Read Answers (2) | Asked by : zanhsieh

Latest Answer : Hi,You can use date functions available to get the dates of a particular monthEx: SELECT col1 FROM TABLE A WHERE TO_CHAR(DATECOLUMN,'MONYY') =  'JUN05'ORSELECT * FROM TABLE A WHERE TO_CHAR(DATECOLUMN,'MON') =  'FEB'Hope this was useful..... ...
Read Answers (1) | Asked by : Saravana Kumar K

Latest Answer : iif=immediate ifiif(isnull(date,0,to_char(date,'yyyy-mm'))if date is not null then 0 else to_char(date,'yyyy-mm');AS SIMPLE AS IT ...

Latest Answer : yeah its very simpleuse the syntax like this:spool   (you can give the path also like c:sarfarazxyz.txt)and to see that whether the result is actually stored in the file or not go to the file menu>open ...


 Sponsored Links

 
Related Articles

What are the limitations with switch statement?

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below: Logical operators cannot be used with switch statement. For instance case k>=20: is not allowe
 

goto Statement

Why to avoid goto in C C has goto statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us understand the goto statement, its
 

UML Elements : Use Case Diagram

UML Elements Use Case Diagram In the Unified Modeling Language a use case diagram is a subset of the behavior diagrams The Unified Modeling Language will utilize the use case diagram as a graphical system which symbolizes use cases mosgoogle center It must be noted that UML will not define the stand
 

How To Select The Best CRM Solution For Your Business

How To Select The Best CRM Solution For Your Business When most people talk about Customer relationship management they use the term in a context that is connected to large corporations However the costs of CRM systems have continued to fall in the last few years and it is now in the price range of
 

Be Prepared for Tech Job Cuts

Even one of the most flourishing and possibly the strongest industries of the future are not experiencing the economic crunch. The tech industry is now experiencing massive job losses in different categories. Although you will still see innovations almost every day from the tech industry through th
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape