Ms SQL查询分组并合并两个表,统计两表
2019-04-29 更新,添加更详细的说明先看效果,如下图,这是Ms sql语句,其它数据库库的语句也差不多大同小异//sql语句 --原创来自 http://www.luofenming.com/show.aspx?id=ART2018120100001 select fh,name,sfxm,sum(ISNULL(je,0)) as je,sum(ISNULL(ssje,0)) as ssje from …
2019-04-29 更新,添加更详细的说明先看效果,如下图,这是Ms sql语句,其它数据库库的语句也差不多大同小异//sql语句 --原创来自 http://www.luofenming.com/show.aspx?id=ART2018120100001 select fh,name,sfxm,sum(ISNULL(je,0)) as je,sum(ISNULL(ssje,0)) as ssje from …
先看一下示例图很多人两个表用union all连接查询,结果跟想象的不一样 以下是 SQL两个不同字段的表合并查询成一个DataTable 的SQL查询样列 select bianhao,fs,zc, null as sr from Table_1 union all select bianhao,fs,null as zc,sr from Table_2 --在此要注意两表的列数…