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

the function CASE in a view...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hi folks,

when I execute this query:
replace view vw_sales as
select a.anvr_nummer
,a.naam
,a.adres
,a.plaats
,a.postkode
,a.sorteerkode
,res.reserveringsnummer
,res.gidscode
,res.reissom
,CASE res.scope
when 's' then 1
else 0
END 'scope'
,nr.pax
,nr.seizoen
from oad.agent a
inner join oad.reservering res
on a.anvr_nummer = res.anvr_nummer
inner join view_resnummers nr
on res.reserveringsnummer = nr.reserveringsnummer


in Queryman 5.1.1, it returns this error:

3706: Syntax error: expected something between the 'END'keyword and the string 's'keyword.

But when I remove the first line ('replace... as') the query executes fine. Are CASE's prohibited in views or something? [surprise]
 
Put parenthesis around the case statement, and take the quotes off the column name.

,res.reissom
,(CASE res.scope
when 's' then 1
else 0
END) as scope
,nr.pax

You don't need quotes on the alias unless its a reserved word, I don't think scope is, then I believe you use double quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top