我有一个语句如下select cast(yhzh as char(20))+cast(object_name as char(10))+cast(gh as char(10))+cast(1 as char(10))+cast(idcard_num as char(20))+cast(btje as char(16))+' ' from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx where t_sn_object.id=t_sn_object_zhxx.btdx_uid and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid and month(djrq)=12 order by gh我欲把gh相同的合并为一行,btje取合计数,该如何写,菜鸟问题,请不吝赐教
max(
cast(yhzh as char(20))+
cast(object_name as char(10))+
cast(gh as char(10))+
cast(1 as char(10))+
cast(idcard_num as char(20))+
cast(btje as char(16))+' '
)
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid
and month(djrq)=12
order by gh
可否用sum ? group by ?
可是我不会用,继续请教