日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

特殊SQL示例

發(fā)布時間:2024/7/23 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 特殊SQL示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
ProductsData
pd_num ? ? ? ? ?pd_type ?pd_status
SCS-1-00 ? ? ? SCS-1 ? ? 0
SCS-1-002 ? ? SCS-1 ? ? 0
SCS-2-001 ? ? SCS-2 ? ? 0
SCS-2-001 ? ? SCS-2 ? ? 1

結(jié)果(num1 是pd_status=0的個數(shù),num1 是pd_status=1的個數(shù))

pd_type num1 ? num2
scs-1 ? ? 2 ? ? ? ? ? 0

scs_2 ? 1 ? ? ? ? ? ?1


select distinct t3.up_type, t3.up_num, iif(isnull(t4.num), 0, t4.num) as non_num from (select distinct t1.pd_type as up_type, iif(ISNULL(t2.num), 0,t2.num) as up_num from ProductsData as t1 left join (select pd_type, count(pd_num) as num from ProductsData where pd_status = 0 group by pd_type) as t2 on t1.pd_type = t2.pd_type) as t3 left join (select pd_type, count(pd_num) as num from ProductsData where pd_status = 1 group by pd_type) as t4 on t4.pd_type = t3.up_type

總結(jié)

以上是生活随笔為你收集整理的特殊SQL示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。