• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL question - the missing ID

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

quick question:

SELECT ID, COUNT(ID)+1 AS numFamily FROM tableA Group By ID

the result for this query will be somthing like:

105 4
106 8
107 3
109 4

the problem is (and this is my question) what if ID=108 is not mention in this table (it exist but in a different table) how can I get a result where:

105 4
106 8
107 3
108 1 //<-- added this (the num one is there becuase I COUNT(ID)+1 )
109 4


thanks for any help
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
Use a "union". Look it up in the documentation for the database you are using.

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic