Skip to content
Advertisement

Create temporary table to display missing months from query

I am trying to create a simple MySQL query to get the sales data for each month of the year, grouped by monthname and SalesName.

The results are correct for the AverageMonthlyRevenue but return total nonsense for ClosedDeals.

Source database:

Result:

Advertisement

Answer

The error is in your Sales temporary table. Without adding DISTINCT you’re just duplicating records. You need to do :

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