i'm working with the airplanes, carriers and flight data base from the stat-computing.org
there is a Flights table with flights numbers (TailNum) and distances (Distance) for every flight
the SQL query that i working with is below:
it is quite simple and works fine, except that i got the sum of the Distance for all the flights in the first result row, and only after, the grouped result by TailNum. Why i got this first row with the total distance for all flights??
SELECT TailNum, SUM(Distance) AS totalDistance
FROM Flights GROUP BY TailNum ORDER BY totalDistance DESC LIMIT 10;
create table
andinsert into
statements so people can easily copy and paste them.