SQL查詢問題(統計模組查詢功能多表複雜查詢)請教SQL達人

2023-01-19 10:20:28 字數 617 閱讀 9152

1樓:

請參考以下語句:

select t1.rq1 as rq ,isnull(x.xs_m,0) as xs_m, isnull(c.cg_m,0) as cg_m

from (

select rq as rq1 from cgunion

select rq from xs) as t1left join (select rq ,sum(m) as cg_m from cg group by rq) c on t1.rq1=c.rq

left join (select rq ,sum(m) as xs_m from xs group by rq) x on t1.rq1=x.rq

其實就是把一樓兄弟的語句改了改。希望可以幫助到你

2樓:藍靈飄雪

select t1.rq1,isnull(cg.m,0),isnull(xs.m,0)

from (

select rq as rq1 from cgunion all

select rq from xs) as t1left join cg on t1.rq1=cg.rqleft join xs on t1.rq1=xs.rq

sql查詢問題

你這問題好模糊,連表欄位都沒有給出,給你大概寫下,select 訪問人 from 表 where convert varchar 7 日期欄位,120 2014 04 有問題再追問吧 select convert varchar 7 date,23 as date,count from testip...

sql查詢問題

mysql select from a id b num 1 b1 200 2 b1 300 3 b1 400 4 b2 120 5 b2 920 5 rows in set 0.00 sec mysql select b,sum num from a group by b b sum num b1...

sql中的查詢問題

select name from user where userid in select id from information where score 60 當選出的id無重複時用這個,如 1,2,3 select name from user where userid in select dis...