Created
June 10, 2020 23:23
-
-
Save rohithBirdeye/14a16e4269bd305cdcddb7e83866d572 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
b.business_id,b.name,bb.payment_status,bb.last_bill_paid_on,b.status,b.activation_status | |
from | |
business b | |
inner join | |
business_billing bb | |
on bb.business_id = b.id | |
where | |
b.status = 'active' | |
and bb.payment_status in | |
( | |
'Expired', | |
'Cancelled' | |
) | |
and b.reseller_id = 1 | |
and b.enterprise_id is null | |
and b.account_type = 'Direct'; | |
select | |
b2.name, | |
b2.business_id, | |
b2.status, | |
bb2.payment_status, | |
bb2.last_bill_paid_on , | |
b2.activation_status | |
from | |
business_billing bb2 | |
inner join | |
business b2 | |
on b2.id = bb2.business_id | |
and b2.enterprise_id in | |
( | |
select | |
b.id | |
from | |
business b | |
inner join | |
business_billing bb | |
on bb.business_id = b.id | |
where | |
b.status = 'active' | |
and bb.payment_status in | |
( | |
'Expired', | |
'Cancelled' | |
) | |
and b.account_type = 'Direct' | |
) | |
and b2.status = 'active' | |
and bb2.payment_status in ( | |
'Expired', | |
'Cancelled' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment