sql server - SQL DISTINCT for 2 Columns WHERE 3rd column = value -
i'm trying select count of distinct columns col 1 & col 2 col 3 = "complete".
firstly don't know how make distinct apply col 1 & col 2 opposed distinct own columns. secondly how exclude col 3 distinct..
select count(*) count (select distinct dp, rn ecount et = 'complete') rows
any thoughts?
example
col1 col2 col3 dp01 rn01 complete yes dp01 rn02 incomplete dp02 rn03 complete dp02 rn03 incomplete dp01 rn04 complete yes dp02 rn05 complete yes dp03 rn06 incomplete
result = 3
i don't think need include column 3 (aka, col et
) in select
part, can use in where
statement directly.
so in example:
select count(*) count (select distinct dp, rn ecount et = 'complete' ) rows
Comments
Post a Comment