Home > database >  According to all kinds of statistics on a monthly basis
According to all kinds of statistics on a monthly basis

Time:10-03

Turn to

From January 2013 to 2014.2 in monthly total number of statistics, the statistics of three types of each month (A/B/C) the number of how many





CodePudding user response:

The select TO_CHARDATE, 'yyyy - mm), count (*) from the original table GROUP BY TO_CHAR (DATE,' yyyy - mm)


I can only according to the statistics and the total number per month, not what conditions will be divided into types

CodePudding user response:

Borrow the original poster statement

The select TO_CHARDATE, 'yyyy - mm),
Count (distinct TYPE)
From the original table
GROUP BY TO_CHAR (DATE, 'yyyy - mm)

CodePudding user response:

I tried the following, with your statement, if not,

CodePudding user response:

 select TO_CHAR (DATE, 'yyyy - mm), 
Count (*),
The count (case when type='A' then type end) A_type,
The count (case when type='B' then type end) B_type,
The count (case when type='C' then type end) C_type
From the original table
GROUP BY TO_CHAR (DATE, 'yyyy - mm);

CodePudding user response:

Thank you very much, success, and not too will use the COUNT nested conditional statements,,

CodePudding user response:

No basis of database, myself, tinkering with the whole morning, and also didn't do well, thank you friends
  • Related