SQL question

From: Bill Morgan <wmorgan_at_nswc.navy.mil>
Date: 1998/02/18
Message-ID: <1998Feb18.154942.3094_at_relay.nswc.navy.mil>#1/1


[Quoted] [Quoted] I have a table with the following 2 columns:   DEPARTMENT VARCHAR2(30)
  DATE_APPROVED DATE I am trying to figure out if it is possible to write a single SQL statement to give me a list of all distinct departments and the percentage of records for each department that have the DATE_APPROVED column less than 3 years old. I can get the total records for each department with:

  Select distinct department,count(*) from my_table   group by department;

I can get the total records with DATE_APPROVED less than 3 years for each department with:

  Select distinct department,count(*) from my_table   where add_months(date_approved,36)>sysdate   group by department;

My question is, can these be combined somehow into one SQL statement that will give the ratio of the two numbers for each department? Please email any replies as well as posting to this group. Many thanks!


[Quoted] William E. Morgan	  NAVAL SURFACE WARFARE CENTER
Code N83          	  email: wmorgan_at_nswc.navy.mil
17320 Dahlgren Rd.	  phone: (540)653-8446,(540)653-7151
Dahlgren, VA  22448	  fax: (540)653-1810
Received on Wed Feb 18 1998 - 00:00:00 CET

Original text of this message