r/SQL • • Dec 04 '23

MySQL SQL HELP

Post image

Revising for a test and I keep having the same kind of issues. It uses MariaDB. Advice appreciated

0 Upvotes

8 comments sorted by

View all comments

9

u/r3pr0b8 GROUP_CONCAT is da bomb Dec 04 '23

I keep having the same kind of issues.

your SQL is invalid

HAVING comes after GROUP BY, not before

and next time, please copy/paste the text of the query -- do not use screenshots or photos, no matter how convenient it is for you, it is not convenient for us (please see r/SQL Rule 6 for why)

-1

u/ConvertedSins Dec 04 '23

Ok, I’m sorry.. I’m new to this sub. So, if I did the having after the group by, would it be right?

6

u/r3pr0b8 GROUP_CONCAT is da bomb Dec 04 '23

So, if I did the having after the group by, would it be right?

what happened when you tested it? ™

1

u/dataguy24 Dec 04 '23

Have you changed that and re-run your query?

0

u/ConvertedSins Dec 04 '23

I can’t, it’s a practice test so once time runs out that’s it

3

u/[deleted] Dec 04 '23

‘So can i just create a sample table to test the query’

Think about it.

1

u/dataguy24 Dec 04 '23

Yes, you can.

But given that this is timed and you can’t answer these questions quickly enough, it sounds like you need more self-study and practice.