sql-group by用法

group by:对数据进行分组,实现分类汇总

获取产品类别的单价合计

select CategoryName,ProductName,UnitPrice from northwind.categories right join northwind.products on northwind.categories.CategoryIDhahah =
northwind.products.CategoryID 

sql-group by用法_第1张图片

注意事项:

sql语句中包含了group by。那么,查询的字段要么作为分组的依据;要么是使用了聚合函数,不然会报错哦

sql-group by用法_第2张图片

 

你可能感兴趣的:(功能测试)