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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select and Case statement

Status
Not open for further replies.

morfasie

IS-IT--Management
Mar 28, 2004
85
ZA
Why can't I do this??
Select (case production.`Policy Name` when 'Pensioner Funeral Plan' then ( select b.`Policy Number`
from pensionerfuneralplan b, production a where b.`Policy Number` = a.`Policy Number`) end)
from production

I want the select inside the case???

Thanks
 
pretty tricky, especially since you give no ELSE clause for the CASE

it appears you do not need the "b" table at all, since when you do want it, the only column you want is b.`Policy Number` and that's equal to a.`Policy Number` anyway
Code:
select 
  case when `Policy Name` 
        = 'Pensioner Funeral Plan' 
       then `Policy Number` 
   end 
 from production

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top