sql - How to add a where clause to a column from a correlated subquery -
i have following correlated subquery in sql server works fine
select *, [status]=(select max([status]) data_121emaillog o2 o2.data_121id = o1.data_121id) data_121 o1
you can see what's going on here screenshot
however, when try add clause on column in generated subquery doesn't work
how can added clause on [status] column. in example should return 1 result there 1 record status of 2.
following comment link marcinjuraszek solved me
select * ( select *, [status]=(select max([status]) data_121emaillog o2 o2.data_121id = o1.data_121id) data_121 o1) a.[status] = 2
Comments
Post a Comment