database - SQL counts of tests given in year -
I am trying to make a sum of the tests given in one year from a specific table. This is what I have done so far: gives me the output: Now, I understand that my problem lies here: EDIT: Thanks to the help of below I get the desired output Was able, but both of them were "wrong", so I did not accept them (sorry if this is a wrong step). Here's my script: Order by year ASC by test_record GROUP TO_CHAR (test_date, 'YYYY') from You want a group in the year and not the date of the trial. SELECT DISTINCT TO_CHAR (test_date, 'YYYY') AS year, from SUM (year card) (SELECT COUNT (test_date) as the year) test_record GROUP by test_record.test_date ORDER BY year ASC;
month of the year (year) ---- -------------- 1958 12 1991 12 1996 12 1998 12 2000 12 2001 12 2010 12 2012 12 2013 12
SELECT COUNT (test_date) as YearCount , because I have 12 entries in the table, so it is clearly calculating the number of entries in the table. I need to count the tests given in each year, i.e. Must appear:
year totals (year) ---- ------------ - 1958 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 4 (I'm using Oracle 7 I believe)
selection number (*), to_date ('YYYY', test_data) as the year by test_record group to_date ('YYYY', test_date) Div>
Comments
Post a Comment