Skip to content
Advertisement

SQL alias inside a Count

I’m trying to learn some SQL, and I feel like I should be able to do this, but I get a syntax error.

It allows me to do

but for the question the first column has to be named Score.

I’ve seen other answers for this problem that seem really complicated, but if anyone has a simple way to make this idea work I’d appreciate it.
Thanks!

Advertisement

Answer

I think you want:

Note that I aliases both table references and all column references.

Of course, this is simpler:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement