sql之分组查询

错误示例

select  PMId,GJTypeId,GJXHCode,GJMonomer,GJFloor,GJLong,GJWidth,GJHigh, convert(decimal(18,4),GJFL) AS GJFL,count(1) GJSum from GJ_ProjectGJ 
where PMId=2155 and GJMonomer='4#' and GJXHCode='YB48.24.1' 
group by PMId,GJTypeId,GJXHCode,GJMonomer,GJFloor,GJLong,GJWidth,GJHigh,GJFL

正确示例

select  PMId,GJTypeId,GJXHCode,GJMonomer,GJFloor,GJLong,GJWidth,GJHigh, convert(decimal(18,4),GJFL) AS GJFL,count(1) GJSum from GJ_ProjectGJ 
where PMId=2155 and GJMonomer='4#' and GJXHCode='YB48.24.1' 
group by PMId,GJTypeId,GJXHCode,GJMonomer,GJFloor,GJLong,GJWidth,GJHigh,convert(decimal(18,4),GJFL)

 一点小差池,会导致显示的数据出现问题

转载于:https://www.cnblogs.com/LessIsMoreZ/p/9675287.html

你可能感兴趣的:(sql之分组查询)