SunQuest
           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 January 10th, 2005, 10:19 AM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Oracle Query Question

Hello...

I'm starting to get the hang of this Oracle thing, however, I have a query that I'm having difficulty with.

I have 2 tables with the following information
Table 1
--------
SubGroupId
infoType
infoCount

Table 2
-------
GroupId
SubGroupId

I need to perform a query that will list a total of all of the infoCount information for a given groupId and a given infoType.

For instance, I may have 2 subgroups belonging to a single group id. However, I want to find out the total of the two infoCounts for each different infoType.

Can someone please help?
Thanks!

Reply With Quote
  #2  
Old January 10th, 2005, 10:26 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
Code:
select sum(infoCount)
from table1
where infoType = <yourGivenValue>
and subGroupId in (select subGroupId
  from table2
 where groupId = <yourGivenValue>)


Not sure what you mean by "the total of all of the infocount" though.

Reply With Quote
  #3  
Old January 10th, 2005, 10:35 AM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Thanks swampBoogie. Except I made a minor error in my question. I really do not have a field called "infoCount" rather there is an entry for each subGroupId of a givent infoType. And I need to count up each of these records that apply to each GroupId.

Thank you

Quote:
Originally Posted by swampBoogie
Code:
select sum(infoCount)
from table1
where infoType = <yourGivenValue>
and subGroupId in (select subGroupId
  from table2
 where groupId = <yourGivenValue>)


Not sure what you mean by "the total of all of the infocount" though.

Reply With Quote
  #4  
Old January 10th, 2005, 11:31 AM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Sorry, there was a mistake made earlier...

There is not an infoCount variable available. Rather there is an entry in the table for each instance of the item. So basically there could be 2 items with the same sub group id, and same infoType.

Any suggestions?

Reply With Quote
  #5  
Old January 10th, 2005, 12:53 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
Like

Code:
select count(*)
from table1
where infoType = <yourGivenValue>
and subGroupId in (select subGroupId
  from table2
 where groupId = <yourGivenValue>)


?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle Query Question


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