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)

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

posted @ 2018-09-19 16:32  张追逐  阅读(348)  评论(0编辑  收藏  举报