thomasnield / oreilly_getting_started_with_sql

Database files for the O'Reilly book "Getting Started with SQL: A hands on approach for beginners" http://goo.gl/z3zG54
404 stars 175 forks source link

Code not working. #7

Open anmoljain1230000 opened 3 years ago

anmoljain1230000 commented 3 years ago

Kk @

![20210119_134543](https://user-images.githubusercontent.com/77664305/105007144-a1ec2c00-5a5d-11eb-8766-4337c288c3df.jpg)

SilvioCruzDeveloper commented 6 months ago

The SQL query you found appears to have some syntax errors. I'll correct it and check if it's wrong

Here's the corrected SQL query:

SELECT year, SUM(precipitation) as total_snow, MAX(precipitation) as max_precipitation FROM STATION_DATA WHERE year >= 2000 GROUP BY year; Changed SUM(precipitation) as max precipitation to MAX(precipitation) as max_precipitation to find the maximum precipitation value.

Corrected WHERE YER >=2000 to WHERE year >= 2000 to compare the year correctly.

This query should now work correctly to calculate the total snow precipitation (total_snow) and the maximum precipitation (max_precipitation) per year starting from 2000 in the STATION_DATA table.