Created
June 11, 2024 15:40
-
-
Save OneWeb/e123a8ad32ef8a07bb297a296fd9cab3 to your computer and use it in GitHub Desktop.
Collector Points Balance SQL
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 | |
(SELECT COALESCE(SUM(r.points_value), 0) FROM gc_promo_receipt r | |
WHERE r.user_id = 1 | |
AND r.status = 'Approved') | |
- | |
(SELECT COALESCE(SUM(l.reward_type_points_cost), 0) FROM gc_promo_user_reward_claim_ledger l | |
INNER JOIN gc_promo_user_reward_claim c ON c.id = l.user_reward_claim_id | |
WHERE c.redeemed_by_user_id = 1) | |
AS points_balance; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment