Click here to Skip to main content
15,913,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a question regarding my SQL statement. I want to sum the value of differenz.
How di I do this?

SQL
SELECT a.spielername AS spielername, count(a.koord) AS anzahl, b.name, b.planeten AS planeten, b.planeten - count(a.koord) AS differenz
                     FROM vs_universum a
                     INNER JOIN vs_highscore b
                     ON a.spielername = b.name
                     WHERE b.datum = :datum
                     GROUP BY b.name
                     HAVING count(a.koord) <> b.planeten


Thank you very much

With kind regards

Tobi

What I have tried:

I tried to sum differenz but this throws an error.
Posted
Updated 11-Jun-20 22:15pm

1 solution

You can't retrieve individual columns when there is a GROUP BY in effect, unless the column is part of the GROUPing condition: SQL GROUP By and the "Column 'name' is invalid in the select list because..." error[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900