sql - How to query list of unique records from many to one relationship data structure? -


i having trouble finding suitable query in sql server. have department(table a) having many clients(table b) data structure. looking query retrieve 1 client(first occurrence) of each department client status active. help?

try

select *  table1 t1       exists      (         select * table2 t2          t1.column1 = t2.column1 , column2 = 1     )     , exists     (         select * table2 t2          t1.column1 = t2.column1 , column2 = 2     ); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -