Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Query to get the count from child table for each data in Master Table

Ramesh SelvamJun 19 2019 — edited Jun 19 2019

Hi,

I have a master table like below:

Sales Type Table

=============

Sales Type
Online
Store Purchase
Door Delivery

And Child Table like below.

Purchase Table

============

Purchase idPurchase TypeCustomer id
1Online100
2Door Delivery101
3Door Delivery102
4Door Delivery103
5Online104
6Door Delivery105
7Door Delivery106
8Online107

                                                    

Purchase idPurchase TypeCustomer id
1Online100
2Door Delivery101
3Door Delivery102
4Door Delivery103
5Online104
6Door Delivery105
7Door Delivery106
8Online107

I need output like below:

Sales TypeNo of Sales
Online3
Store Purchase0
Door Delivery5

Kindly help me on how to achieve it in SQL.

Thanks.

This post has been answered by Frank Kulash on Jun 19 2019
Jump to Answer
Comments
Post Details
Added on Jun 19 2019
13 comments
4,472 views