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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 24th, 2004, 10:54 AM
jap150 jap150 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 jap150 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Need help on SQL statement

I am trying to get subtotals and grand total figures on total_res and actual_hours_posted using a case statement and am having problems. Can you help me? See below in Blue. Thanks!

SELECT
p.unique_name project_code,
p.name project_name,
tp.prstart fiscal_week_start,
tp.prfinish fiscal_week_finish,
count(distinct a.prresourceid) as total_res,
cc.prname charge_code,
SUM(DECODE(ts.prstatus,4,(NVL(te.practsum,0)/3600),0))
actual_posted_hours,
sum(case when substr(p.name,1,5) = 'Admin%' then (actual_posted_hours + 0) as fiscal_week_admin_hours
End

Reply With Quote
  #2  
Old March 24th, 2004, 11:36 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
case expressions are not supported in all versions of Oracle. Why can't you use decode?

Reply With Quote
  #3  
Old March 24th, 2004, 01:13 PM
jap150 jap150 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 jap150 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Need help on SQL statement

Have tried. Can't get it to work. Can you help?

Reply With Quote
  #4  
Old March 24th, 2004, 01:56 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Code:
sum(decode(substr(p.name,1,5) ,'Admin' ,actual_posted_hours ,0)
 as fiscal_week_admin_hours


I spotted an error in your case expression syntax

Code:
sum(case when substr(p.name,1,5) = 'Admin' then actual_posted_hours else 0 end) as fiscal_week_admin_hours

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Need help on SQL statement


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 1 hosted by Hostway