Examples of Count, Count IF, Count duplicates in SQL

Count: SELECT [ProductModel], COUNT(1) CNT FROM [AdventureWorks2017].[Production].[vProductAndDescription] GROUP BY [ProductModel] ORDER BY CNT DESC Count "if": SELECT [ProductModel], [Name],COUNT(1) CNT FROM [AdventureWorks2017].[Production].[vProductAndDescription] WHERE [ProductModel] LIKE '%Frame' AND [Name] LIKE '%52' --here's the IF statement GROUP BY [ProductModel], [Name] ORDER BY CNT DESC Count duplicates: SELECT [ProductModel], COUNT(1) CNT -- select a field you want to … Continue reading Examples of Count, Count IF, Count duplicates in SQL