oracle - Use of AVG function to determine percentages in a SQL query -


I know what percentage of the records are given values, where the percentage is defined as the number of records Which corresponds to the value divided by the total number of records i.e. 100 records, 10 of which have a zero value for student_id and 20 is 999999, then percent_999999 should be 20%. Can I use the average function to determine this?

Option 1:

  SELECT year, college_name, sum (case when student_id IN ( '999999999') again as count_id_999999999, count_id_999999999 / total_id as percent_id_999999999, the amount ( case when student_id number of zeros after the 1) as count_id_NULL, as count_id_NULL / total_id by percent_id_NULL count (Kul_aidi Enrolment_data ad group as *) year Colej_nam by year Colej_nam option 2:  < pre>  SELECT year, college_name, sum (case when student_id iN ( '999999999') and 1 and 0 end) as count_id_999999999, average (case when student_id iN ( '999999999') then 1.0_id_999999999 as W As Ratist_ id_999999999, sum (case when case_id_NULL, the case (when Chhatr_aidi tap 1 and 0 at the end), average (Case_id_id_NULL) count (*) as Kul_aidi Enrolment_data ad group by year, by Colej_nam order year Colej_nam; I 100 Records 20 99 99 99 99 99 9 10 taps and built a table with 70. 1s. it worked for me on SQL server:  
  select number (*) ScratchTbl Group StudentID from StudentID; (No column names) StudentID 10 NULL 70 1 20 99 99 99 99 9 Select Average (case when StudentID = '999999999' then as 1.0 and 0.0 at the end) 'pct_9s', sum (case when StudentID = '999999999' Then 1 and 0 in the form of 'count_9' as 'count_null' from 'Scratchable', in the form of 'calcul_9', average (when student id is empty, 1.0 other 0.0 end), 'pct_null', (when student ID is zero, Then the case) count_9s pct_null count_null 0.200000 20 0.100000 10  

I think the use of the group by section can cause problems for you, maybe one Select the distinguished year / college where use the segment (and get rid of the group from the line) and see if you get results.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -