Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select (
- -- all udprns used on non-deleted prospects and customers >>>
- (select count(udprn) from (
- select udprn from prospects join addresses on addresses.id = address_id and deleted_at is null and udprn is not null
- union all
- select udprn from customers join addresses on addresses.id = address_id and deleted_at is null and udprn is not null) as tbl1)
- -- minus >>>
- -
- -- unique udprns used on non-deleted prospects and customers >>>
- (select count(distinct udprn) from (
- select udprn from prospects join addresses on addresses.id = address_id and deleted_at is null and udprn is not null
- union all
- select udprn from customers join addresses on addresses.id = address_id and deleted_at is null and udprn is not null) as tbl2)
- ) as tbl3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement