SQL Server - Compare on multiple columns in differnet rows within same table -
i have table holds values read 2 meters:
---------------------------- date | meterid | value ---------------------------- 1/2/14 1.3 2/2/14 1.8 2/2/14 b 3.8 3/3/14 1.2 4/3/14 1.8 4/3/14 b 2.9
i need query count number of days reading exists both meter types (a
& b
)? in illustration above should yield 2 result.
thanks.
you can utilize temporary table list [date]
s when there occurrences in meterid
both a
, b
, count()
[date]
s :
select count(t.*) ( select [date] [table] grouping [date] having count(distinct [meterid]) = 2 ) t
sql sql-server compare
No comments:
Post a Comment