触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > 在主表中显示附表合计
主表GGNR(select * from ggnr)
ID GGBH(编号) GTITLE GFILE
63 GONG201102020001
标题 内容

附表(select * from ggnrfj)
IDSTR GGBH(编号) FJFILENO FJFILEIMAGE
EMA201106110001 GONG201102020001
11111111122222222.txt /upload//email/46d806c9-8bda-4ff7-806c-1d81c439be19.txt
EMA201106110002 GONG201102020001 2.txt /upload//email/46d806c9-8bda-4ff7-806c-1d81c439be20.txt

结果(select a.*,isnull(e.fjnum,0) as fjnum from ggnr a left join (select f.ggbh,count(*) as fjnum from ggnr f join ggnrfj g on
f.ggbh=g.ggbh group by f.ggbh) e on a.ggbh=e.ggbh)
ID GGBH GTITLE GFILE fjnum(合计数)
63 GONG201102020001
测试一下 测试一下 2

注:如果加查询条件如下:
select a.*,isnull(e.fjnum,0) as fjnum from ggnr a left join (select f.ggbh,count(*) as fjnum from ggnr f join ggnrfj g on
f.ggbh=g.ggbh(加查询条件where 周下) group by f.ggbh) e on a.ggbh=e.ggbh(加查询条件where 周上)


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com