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

enter image description here

however, when try add clause on column in generated subquery doesn't work

enter image description here

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

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -