SQL to find the year (1 Viewer)

Joy83

Member
Local time
Today, 05:42
Joined
Jan 9, 2020
Messages
116
Hello,
I have a field that contains the date in this format 201109 integer
Each row includes cost and that field
I want to build sql that gets me the the amounts by year?
 
Last edited:
Code:
SELECT SUM(cost) as total_cost
FROM your_table
WHERE date LIKE '%2011%'
 
SQL:
SELECT
   your_Date \ 100 AS [year],
   SUM(cost) AS total_cost
FROM
   your_table
GROUP BY
   your_Date \ 100
 
I have a field that contains the date in this format 201109 integer
You should explain the format.
Without further explanation, the year could be 2020, 2011, or 2009 to name just the most plausible.
 

Users who are viewing this thread

Back
Top Bottom