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: 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;

gives me the output:

  month of the year (year) ---- -------------- 1958 12 1991 12 1996 12 1998 12 2000 12 2001 12 2010 12 2012 12 2013 12   

Now, I understand that my problem lies here: 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)  

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 SELECT TO_CHAR (test_date, 'YYYY') AS year, COUNT (test_date);

You want a group in the year and not the date of the trial.

  selection number (*), to_date ('YYYY', test_data) as the year by test_record group to_date ('YYYY', test_date) Div> 

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -