Aggregates not functioning

I on the aggregates lesson. None of my Aggregate functions are working. None of them turn blue. I checked to make sure there are no spaces, i.e., MAX(), AVE(). They are still grey with no function. I am working MySQL from a Mac OS 12.2 (idk if it matters or not). Any suggestions?

Are you including the column name e.g. MAX(price) or AVG(price)? Do you have a screenshot?

I’m sorry I don’t. I have tried it w the column name in () no spaces, and without e.g. MAX() and it’s just light grey - no blue and no function.

hey , I am also currently experiencing the same problem. Were you able to sort it out ? if so can you please help with it as well ?

Hi, I have the same issue. Did you mange to fix it ? Can you share how ?

Try below code

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)-SUM(payment_total) AS what_we_expect
FROM invoices
WHERE due_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)-SUM(payment_total) AS what_we_expect
FROM invoices
WHERE due_date BETWEEN  '2019-01-01' AND '2019-12-31'

Hi, I have the same problem with SUM and I tried this code and it’s still not working.

@shrikantkalar023 code works
what error message did you receive when you ran the code?
Did you select a database?

this is what i got when i ran the code; Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')

Try

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 
sql_invoicing.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 
sql_invoicing.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 
sql_invoicing.invoices
WHERE invoice_date
    BETWEEN '2019-01-01' AND '2019-12-31';

This worked, thank you so much for help

1 Like