I am new to SQL
I was trying this assignment and wanted to calculate total duration of pandemic in months, for which I used DECLARE, but it shows error of not in valid position, what is the issue here?
I am using MySQL Workbench
<code>SELECT *
FROM corona_analysis.corona_dataset
WHERE Province is null
OR Country is null
OR Latitude is null
OR Longitude is null
OR Date is null
OR Confirmed is null
OR Deaths is null
OR Recovered is null;
SELECT COUNT(*) total_rows
FROM corona_analysis.corona_dataset;
SELECT MIN(Date) AS start_date,
MAX(Date) AS end_date
FROM corona_analysis.corona_dataset;
DECLARE @start_date DATE='2020-01-22',
DECLARE @end_date DATE='2021-06-13';
SELECT (DATEDIFF(MONTH, @start_date, @end_date)) AS number_of_months;
</code>
<code>SELECT *
FROM corona_analysis.corona_dataset
WHERE Province is null
OR Country is null
OR Latitude is null
OR Longitude is null
OR Date is null
OR Confirmed is null
OR Deaths is null
OR Recovered is null;
SELECT COUNT(*) total_rows
FROM corona_analysis.corona_dataset;
SELECT MIN(Date) AS start_date,
MAX(Date) AS end_date
FROM corona_analysis.corona_dataset;
DECLARE @start_date DATE='2020-01-22',
DECLARE @end_date DATE='2021-06-13';
SELECT (DATEDIFF(MONTH, @start_date, @end_date)) AS number_of_months;
</code>
SELECT *
FROM corona_analysis.corona_dataset
WHERE Province is null
OR Country is null
OR Latitude is null
OR Longitude is null
OR Date is null
OR Confirmed is null
OR Deaths is null
OR Recovered is null;
SELECT COUNT(*) total_rows
FROM corona_analysis.corona_dataset;
SELECT MIN(Date) AS start_date,
MAX(Date) AS end_date
FROM corona_analysis.corona_dataset;
DECLARE @start_date DATE='2020-01-22',
DECLARE @end_date DATE='2021-06-13';
SELECT (DATEDIFF(MONTH, @start_date, @end_date)) AS number_of_months;
How can I rectify this issue?
New contributor
Anshul Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.