![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've got two tables: TableA has 4 columns that make up the key (A1, A2, A3, A4). TableB has 5 key columns; 4 of which are made up of the key from TableA. TableB's key is (A1, A2, A3, A4, SeqNum). Now, what I want to do is form a query that will give me a count of all the rows in TableB with matching A1, A2, A3 and A4 values in TableA. |
#3
| |||
| |||
|
|
select count(*) from table_a a, table_b b where a.a1 = b.a1 and a.a2 = b.a2 and a.a3 = b.a3 and a.a4 = b.a4 Did you mean something else? |
#4
| |||
| |||
|
|
Ed Avis <ed (AT) membled (DOT) com> writes: select count(*) from table_a a, table_b b where a.a1 = b.a1 and a.a2 = b.a2 and a.a3 = b.a3 and a.a4 = b.a4 Did you mean something else? Perhaps he wants a count for each primary key? select a.a1, a.a2, a.a3, a.a4, count(*) from table_a a, table_b b where a.a1 = b.a1 and a.a2 = b.a2 and a.a3 = b.a3 and a.a4 = b.a4 group by a1, a2, a3, a4 |
#5
| |||
| |||
|
|
Hi All, Actually, the one from Ed is what I was after. But, now, both might be useful. I was confused about what how to set up the FROM clause: i.e., what table COUNT(*) would reference: TableA or TableB. But I see now what's happening now. |
|
_ \___ _ _ ___// / -_) ' \/ -_) _|_\___|_||_\___| |
![]() |
| Thread Tools | |
| Display Modes | |
| |