COUNT(DISTINCT) in multiple columns in SQL Server 2008
问题 In Oracle, it's possible to get a count of distinct values in multiple columns by using the || operator (according to this forum post, anyway): SELECT COUNT(DISTINCT ColumnA || ColumnB) FROM MyTable Is there a way to do this in SQL Server 2008? I'm trying to perform a single query to return some group statistics, but I can't seem to do it. For example, here is a table of values I'm trying to query: AssetId MyId TheirId InStock 328 10 10 1 328 20 20 0 328 30 30 0 328 40 10 0 328 10 10 0 328 10