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.
Author |
Topic |
yoyosh
Starting Member
27 Posts |
Posted - 2013-01-30 : 04:19:48
|
Why the following query is incorrect?select (select top 1 date from pass_in_trip p where p.trip_no = t.trip_no) as datefrom trip twhere date is not nullIt says: Invalid column name 'date'. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-30 : 04:25:16
|
date is an alias created in same level so cant be used in where like that. so you need to tweak it like thisselect *from(select (select top 1 date from pass_in_trip p where p.trip_no = t.trip_no) as [date]from trip t)pwhere [date] is not null ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
yoyosh
Starting Member
27 Posts |
Posted - 2013-01-30 : 06:29:34
|
Thank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-30 : 06:48:28
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|