How to do a count on a union query

前端 未结 6 1061
谎友^
谎友^ 2020-12-28 12:32

I have the following query:

select distinct profile_id from userprofile_...

union

select distinct profile_id from productions_...

How wou

6条回答
  •  北海茫月
    2020-12-28 13:07

    If you want a total count for all records, then you would do this:

    SELECT COUNT(*)
    FROM
    (
        select distinct profile_id 
        from userprofile_...
    
        union all
    
        select distinct profile_id 
        from productions_...
    ) x
    

提交回复
热议问题