Hello all, first post :)Maybe you can help me:Here is a pic of the tables
What I am trying to do is return the following query: "Return the number of orders for every client by credit card type",meaning, if for example 'David' has 3 credit cards: 2 'Visa' cards and 1 'MasterCard' card, the answer will contain 1 row of 'Visa' , in which all orders in the 'Visa' cards will be summed, and another row with the number of orders of the 'MasterCard'.The code I have written so far is as follows:SELECT DISTINCT C.cust_name,CC.cust_num,CC.cc_type,COUNT(*)FROM online_shop.customer C, online_shop.credit_card CC, (SELECT C.cust_num,CC.cc_type,CC.cc_num FROM online_shop.customer C, online_shop.order O, online_shop.credit_card CC WHERE C.cust_num=O.cust_num and CC.cc_num=O.cc_num GROUP BY CC.cc_num) AS TempWHERE C.cust_num=Temp.cust_num AND CC.cc_type=Temp.cc_typeGROUP BY Temp.cc_num
But unfortunately the answer that returns is close to what I need but it seems the count is not working properly.Maybe you could tell me what's wrong with my query or perhaps suggest a different and better one.Thanks in advance!