Skip to content

Tag: sql

How to do MAX COUNT so Query returns 1 Result SQL

I have the following query: Which returns the following results: Id EmailDomain UserCount 1 @yahoo.com 1 1 @gmail.com 4 2 @hotmail.com 1 3 @aol.com 1 3 @comcast.com 1 I need the Ids and the Email Domains for a later query, but I don’t want multiple email domains. So I want my results to look like this: …

Sort column values in a particular way

I have 2 tables: I want to get average of points for each student and each course and sort the result by Student ID and Course in order (Mathematics,Physics and Chemistry). The output should be the following: For each Student the course order should be (Math,Phys, Chem) and also it should be ordered by Studen…

Using parent SQL column in subquery

Good morning. I’m trying to pull the username of the user from the column in to_id. Is there. It’d be simple if I was just filtering on to_id, but I also need records from another column from_id. I’ve attempted doing a UNION to get around this issue, but it only pulls records from user.id 3 …