Cyber Space Cyber Space - 1 year ago 29
SQL Question

SQL query involving 2 tables

I have 2 tables just like:-

Table_1 Table_2
--------------- -------------------
id bk_title bk_no bk_isbn
--------------- ---------------------
1 A_Book 1 ISBN0001
2 B_Book 1 ISBN0002
2 ISBN0003

I want to fetch records as
BK_Title Num_Copies
A_Book 2
B_Book 1

Any sql example would be of great help for me.Thanks in advance.


This is a simple INNER JOIN and GROUP BY with a COUNT:

Select  T1.bk_title, Count(*) As Num_Copies
From    Table_1 T1
Join    Table_2 T2  On = T2.bk_no
Group by T1.bk_title