计算转换列和连接列的不同性,并按每条记录分组

时间:2018-11-12 22:24:27

标签: tsql

select
 distinct convert(varchar(8), Creative.Width) + 'x' + convert(varchar(8), Creative.Height) as FormatName 
 from Creative 
 where CreativeFileDate > '1 SEP 18'

查询根据我的连接提取唯一记录。我现在如何最有效地查找每个计数?

谢谢

1 个答案:

答案 0 :(得分:0)

您将要使用分组依据和计数

https://www.w3schools.com/sql/sql_groupby.asp https://www.w3schools.com/sql/sql_count_avg_sum.asp

我的SQL有点生锈,但是您的查询应该类似于:

select convert(varchar(8), Creative.Width) + 'x' + convert(varchar(8), Creative.Height) as FormatName, count(0)
 from Creative 
 where CreativeFileDate > '1 SEP 18'
group by convert(varchar(8), Creative.Width) + 'x' + convert(varchar(8), Creative.Height)

欢呼