I have two tables
One contains a list of users addresses, the other table contains list of orders.
What I want to do is join the tables, get a distinct list of address and the number of orders to the address.
Table1
ID - USERNAME - USERADDRESS
1 - USER1 - ADRESS1
2 - USER2 - ADDRES2
3 - USER3 - ADDRES3
Table2
ID - USERID - ORDERDETAIL
1 - 3 - ...
2 - 2 - ...
3 - 2 - ...
4 - 1 - ...
5 - 3 - ...
6 - 2 - ...
7 - 1 - ...
8 - 3 - ...
9 - 3 - ...
10 - 3 - ...
And Get
ADDRESS1 2
ADDRESS2 3
ADDRESS3 5
How can i do this in one SQL statement?
Aucun commentaire:
Enregistrer un commentaire