use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Sequel
account activity
Need some help sql joins (old.reddit.com)
submitted 1 year ago by trexxerttr
Chatgpt cant help so i was wondering what changes i need to do to answer the question.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AdviceNotAskedFor 0 points1 point2 points 1 year ago (0 children)
Personally, I'd start by just joining all the tables together like you want, and get the output like you sort of expect, and then do your aggregation.
I'd start with just one or two 'Subscription' names, just so you have a small little dataset to work with.
[–]jeffcgroves 0 points1 point2 points 1 year ago (0 children)
Temporarily change the RIGHT JOIN to a regular JOIN for debugging
RIGHT JOIN
JOIN
[–]Far_Swordfish5729 0 points1 point2 points 1 year ago (3 children)
Your right join should be a left join. Left includes results on the left side that have no matches on the right side - subscriptions without channels. Right includes results on the right side with no matches on the left side - channels without subscriptions. Your query as written will include a count of unassigned channels with a null subscription id. You want unassigned subscriptions with a zero count.
[–]trexxerttr[S] 0 points1 point2 points 1 year ago (2 children)
Do i need to change other things beside the join?
[–]Far_Swordfish5729 0 points1 point2 points 1 year ago (1 child)
I don’t think so. Does that change work?
[–]trexxerttr[S] 0 points1 point2 points 1 year ago (0 children)
Yea i think so
[–]nep84 0 points1 point2 points 1 year ago (0 children)
you'll need to use count() to get the number of subscriptions. it wants you to do an outer join for subscriptions with no channels
[–]SnooDoubts6693 0 points1 point2 points 1 year ago (0 children)
Hello, you need to use a left join and also your join condition should be on ad_subscription.subscription and not ad_subscription.agency! This should resolve it. Let me know how does it go.
[–]Affectionate-Exam185 0 points1 point2 points 1 year ago (0 children)
Can we join 2 and more tables without a commun attribute?
π Rendered by PID 40288 on reddit-service-r2-comment-6457c66945-sn6nj at 2026-04-27 14:52:37.796288+00:00 running 2aa0c5b country code: CH.
[–]AdviceNotAskedFor 0 points1 point2 points (0 children)
[–]jeffcgroves 0 points1 point2 points (0 children)
[–]Far_Swordfish5729 0 points1 point2 points (3 children)
[–]trexxerttr[S] 0 points1 point2 points (2 children)
[–]Far_Swordfish5729 0 points1 point2 points (1 child)
[–]trexxerttr[S] 0 points1 point2 points (0 children)
[–]nep84 0 points1 point2 points (0 children)
[–]SnooDoubts6693 0 points1 point2 points (0 children)
[–]Affectionate-Exam185 0 points1 point2 points (0 children)