1樓:鯨魚爸爸
大概明白你的意思。如果你的資料只有三層,並且只是你sql限定的這些資料好辦。
select t3.mc,t2.mc ,t1.mc,t1.* from (select * from sys_zdinfo
where plsh >='2012070900000068' and plsh <= '2012070900000072' ) t1
left join (select distinct lsh,plsh from sys_zdinfo where plsh = '2012070900000009') t2
on t1.plsh = t2.lsh
left join (select distinct lsh,plsh from sys_zdinfo where plsh = '2012070900000009' and plsh = lsh) t3
on t2.plsh = t1.lsh
2樓:生活he家
你這也不解釋說明一下 這兩個表的聯絡 別人怎麼猜啊
sql查詢語句,求大神幫助!
sql 語句求大神幫忙
3樓:
請參閱以下指令碼
select customer.short_name from customer where not exists(
select null from cust_order where cust_order.customer_id=customer.customer_id
and [訂單日期] between '2017-10-18' and '2018-1-18'
)請採納!
sql 語句編寫 求大神幫助!!!
4樓:匿名使用者
select * into testtt
from(
select
1 as a,33 as b
union all select
1,34
union all select
1,35
union all select
2,33)aa
--查詢語句:
select * from testtt
--答案:
select t1.a,t1.b,isnull(t2.count1,0) from
(select * from
(select distinct a from testtt)t1, (select distinct b from testtt) t2)t1 left join
(select a,b,count(1) as count1 from testtt group by a,b )t2 on t1.a=t2.a and t1.b=t2.b
輸出結果:
a b
----------- -----------
1 33
1 34
1 35
2 33
(4 行受影響)
a b
----------- ----------- -----------
1 33 1
1 34 1
1 35 1
2 33 1
2 34 0
2 35 0
(6 行受影響)
5樓:匿名使用者
a和b是同一張表的的兩個欄位嗎,如果是這樣的話可以這樣統計:
select a,b,count(0) as count from 表 group by a,b
6樓:星魂
select a.id,b.id,c.
id,d.id from a inner join b on a.id = b.
id inner join c on b.id=c.id left join d on c.
id = d.id試一下
7樓:匿名使用者
表結構再詳細點,a、b代表兩張表?通過什麼欄位連線?
使用了union,沒有用union allselect a.*,0 cnt from(select x.a,y.
b from test x,test y group by x.a,y.b
minus
select a,b from test) aunion
select a,b,count(*) from test group by a,b;
資料庫sql查詢語句題目,求大神幫忙~
8樓:匿名使用者
(6)select 學號,姓名 from 學生表 a,選課表 b where a.學號=b.學號
and 課程號'5 '
(7)select 學號 from 選課 where 課程號 not in ('5')
(8)select 學號 from 選課 where 課程號 in ('5','6')
(9)select 學號,姓名 from 學生表 a,選課表 b where a.學號=b.學號
and 課程號 in(select 課程號 from 課程表)
(10)select 學號,姓名 from 學生表 a,選課表 b where a.學號=b.學號
and 課程號 in(select 課程號 from 選課表 where 學號='95001')
SQL查詢資料語句問題,SQL查詢資料語句問題
取n到m行 1.select top m from tablename where id not in select top n id from tablename order by id asc desc 2.select top m into 臨時表 或表變數 from tablename or...
sql查詢語句
商品重量有字元肯定不可以直接獲得乘積,假設商品數量和商品重量分別欄位名 amount和weight,新獲取的值存在總克數total中,名稱trade,假設商品id 1,解決辦法如下 select amount cast substring weight,1,len weight 1 as float...
sql查詢指定記錄的條數,sql語句查詢表內資料條數?
sql 使用 count可以統計指定記錄的條數 結合group by 可以統計不同分類的條目數 例子 id name 1 xk 2 kl 3 xk 統計name xk 的條數 select count number from table where name xk 結果number2 關注 upda...