Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Query

 
mash john
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a parent table named Track_locations with org_roadmark and track_location_id as primary keys.

I have 2 child tables online_equip and unload_list_equip with track_location_id,org_roadmark as foreign keys.

I need to retrieve the total count of track_location_id present in both(or either of ) the child tables in a single query.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4028
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Select the count of each using count(*) in the SQL query and then add the results which can also be done in the same SQL statement. Depending on your grouping requirements though, you might get duplicates (for example if the same parent reference appears in both child tables).

Again, your requirements would dictate how to proceed, but if you need the count to be for non-overlapping parents, the UNION command could also help.
[ December 19, 2005: Message edited by: Scott Selikoff ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic