【问题标题】:Sql Count(*) from multiple tables but intersection should come来自多个表的 Sql Count(*) 但应该出现交集
【发布时间】:2022-09-27 21:28:37
【问题描述】:
Select distinct(job_id) from A where condition
Select distinct(job_id) from B where condition
Select distinct(job_id) from C where condition

这里可能1,2和3有一些共同的jobId 我需要的是计算所有可能不会重复的 job_id。

    标签: sql spring postgresql spring-boot spring-mvc


    【解决方案1】:

    与联合?

    Select job_id from A where condition
    UNION
    Select job_id from B where condition
    UNION
    Select job_id from C where condition
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 1970-01-01
      • 2013-09-22
      • 1970-01-01
      • 2019-03-09
      • 2012-10-27
      • 1970-01-01
      相关资源
      最近更新 更多