SQL Count(*) and Group By - Find Difference Between Rows -


Below is a SQL query that I wrote to find the total rows of each product ID (proc_id):

  SELECT proc_id, proc (WHOLE) WHERE grouping_primary = 'SLB' and 'eff_date = '01 -JUL-09' by proc_id ORDER BY proc_id; Below is the result of the SQL query:  
 proc_id count (*) 01 626 02 624 03 626 04 624 05 622 06 624 07 624 09 624  

How do I write an SQL query to know which proc_id lines are different for proc_id = '01', proc_id = '03', and proc_id = '05' compared to other proc_id? First of all, you need to define the criteria that '624' makes right this is the average code

> Count (*) ? Is it count (*) which is most often? Is this your favorite count (*) ?

Then you can use the Housing Clause to separate the person who does not match your criteria:

  SELECT proc_id, count (*) from proc WHERE grouping_primary = 'SLB' and eff_date = '01 -JUL-09 'by proc_id group Howing (*) & lt; & Gt; 624 Order BY proc_id; Select  

or:

  select proc_id, count (*) from Pro WHERE grouping_primary = 'SLB' and eff_date = '01 -JUL-09 ' Proc_id Hewing Calculation (*) by Group & lt; & Gt; (Insert a subquery here that creates magic '624' & gt; ORDER BY proc_id;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -