Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 1st, 2005, 08:24 PM
GrimSage GrimSage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 3 GrimSage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 33 sec
Reputation Power: 0
Question Need SQL Query Help

OK I am tring to create a query and I am not sure how to do it.

example query:

select fcr, count(fcr) from incidents group by fcr;

FCR COUNT(FCR)
--- ----------
N/A 3466
No 8844
Yes 111968

Now what I want is this

FCR COUNT(FCR) % of total
--- ---------- -------------
N/A 3466 0.02
No 8844 0.07
Yes 111968 .91

FOr the life of me I just cant figure this out. ANd I know that it is going to be a really simple answer.

Thank you for any help you can offer

Reply With Quote
  #2  
Old September 2nd, 2005, 03:02 AM
pabloj's Avatar
pabloj pabloj is online now
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,909 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 10 h 31 m 12 sec
Reputation Power: 279
Something like this should do the trick
sql Code:
Original - sql Code
  1. SELECT
  2. fcr,
  3. (COUNT(fcr)/(SELECT COUNT(fcr) FROM incidents))
  4. FROM incidents
  5. GROUP BY fcr;

Reply With Quote
  #3  
Old September 2nd, 2005, 04:38 PM
GrimSage GrimSage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 3 GrimSage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 33 sec
Reputation Power: 0
Thank you, I knew I was over thinking it way to much.
Quote:
Originally Posted by pabloj
Something like this should do the trick
sql Code:
Original - sql Code
  1. SELECT
  2. fcr,
  3. (COUNT(fcr)/(SELECT COUNT(fcr) FROM incidents))
  4. FROM incidents
  5. GROUP BY fcr;

Reply With Quote
  #4  
Old September 5th, 2005, 10:01 AM
GrimSage GrimSage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 3 GrimSage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 33 sec
Reputation Power: 0
OK that worked for oracle 9i but when I try in
SQL*Plus: Release 8.1.6.0.0 - Production
I get the following error

SQL> select fcr, count(fcr), (count(fcr)/(select count(fcr) from incident))*100 "%" from nx_winch_case_details group by fcr;

select fcr, count(fcr), (count(fcr)/(select count(fcr) from incident))*100 "%" from nx_winch_case_details group by fcr
*
ERROR at line 1:
ORA-00979: not a GROUP BY expression

where the * is under the count(fcr) from the nested select statement.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Need SQL Query Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT