Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql view - invalid column

Author  Topic 

akg64912
Starting Member

1 Post

Posted - 2010-10-08 : 14:10:39
CREATE VIEW [dbo].[MyView]
AS
SELECT
FirstName = GivenName,
DOB = DateTimeofBirth,
Age = HLP.Age,
AgeRank = CASE
WHEN Math >= 40 THEN 1
WHEN Math <= 40 THEN 0
END
CASE
WHEN Sex = 'M' THEN 1
WHEN Sex = 'F' THEN 2
END
FROM
TableName
HAVING AgeRank >=3

GO

I am getting invalid column AgeRank.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-08 : 14:14:55
You can use a derived table, but don't you need a group by?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -