Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

aggregate combined with nonaggregate

Status
Not open for further replies.

paubad

Computer
Oct 26, 2006
2
DK
I wish to perform a select in which I join two tables. I want to add an extra field telling me for each selected tuple from table 1 - how many tuples from table 2 were joined with it.

as follows:

table 1:

a %
b %
c +

table 2:

a 1
a 3
a 5
a 7
b 2
b 3
c 4
c 5
c 6

desired result:
a % 1 4
a % 3 4
a % 5 4
a % 7 4
b % 2 2
b % 3 2
c + 4 3
c + 5 3
c + 6 3

 
Replies continue below

Recommended for you

select t.f1,t.f2,f22, (select count(*) from tbl2 where f11=t.f1) as tuples from tbl1 t, tbl2 where f1=f11

f1 is field1 from tabl1
f2 is field2 from tabl1
f11 is field1 from tabl2
f22 is field2 from tabl2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top