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!

Problem with creating view

Status
Not open for further replies.

olapus

Technical User
Apr 26, 2004
2
US
Hello Everyone,

I am having problems in creating this view.

create view age_group_view as
select cust_id, birthdate = case
where DIFF(year,birthdate,getdate()) <= 18 then 1
where DIFF(year,birthdate,getdate()) between 19 and 24 then 2 from dbo.customer

The problem - case statement cannot be used.

Is there any way i can create a view like this or is there any problem with this view.

Thanks


 
create view age_group_view as
select cust_id, birthdate = case
where DIFF(year,birthdate,getdate()) <= 18 then 1
where DIFF(year,birthdate,getdate()) between 19 and 24 then 2 from dbo.customer


Thanks

J. Kusch
 
sorry ...

create view age_group_view as
select cust_id, birthdate = case
when dateDIFF(year,birthdate,getdate()) <= 18 then 1
when dateDIFF(year,birthdate,getdate()) between 19 and 24 then 2 end from dbo.customer


Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top