Summarizing Data - Aggregate Functions exercise

Hi,

Can please someone explain to me why I’m getting this different output for this exercise?
I restored the databases just like the previous video class indicates.
The query that I run is the solution of Mosh

Mosh query output

date_range total_sales total_payments what_we_expect
First half of 2019 1539.07 662.69 876.38
Second half of 2019 1051.53 355.02 696.51
Total 2590.60 1017.71 1572.89

My output

The query that I run is the solution of Mosh

-- USE sql_invoicing;
SELECT 
    'First half of 2019' AS date_range,
    SUM(invoice_total) AS total_sales,
    SUM(payment_total) AS total_payments,
    SUM(invoice_total - payment_total) AS what_we_expect
FROM invoices
WHERE invoice_date BETWEEN '2019-01-01' AND '2019-06-30'
UNION
SELECT 
    'Second half of 2019' AS date_range,
    SUM(invoice_total) AS total_sales,
    SUM(payment_total) AS total_payments,
    SUM(invoice_total - payment_total) AS what_we_expect
FROM invoices
WHERE invoice_date BETWEEN '2019-07-01' AND '2019-12-31'
UNION
SELECT 
    'Total' AS date_range,
    SUM(invoice_total) AS total_sales,
    SUM(payment_total) AS total_payments,
    SUM(invoice_total - payment_total) AS what_we_expect
FROM invoices
WHERE invoice_date BETWEEN '2019-01-01' AND '2019-12-31'

Thanks,

I get the same results as you. Did the total_payments on calculator to confirm the results. My guess is they changed the script that creates the invoices table using different data than when the video was recorded.

1 Like

Hi @blitzmacht,

I think your guess is probably right.

Thanks for your help :+1: