Reputation: 23
My table 'Transactions' has the following columns :
I ran the following query and got some output, but since I don't have the expected output with me.Therefore, I want someone to help me to confirm if this code will always work and suggest edits if it doesn't.
select cust_id, COUNT(cust_id) AS Count_of_Transactions
from Transactions
where Qty >= 0
group by cust_id
having COUNT(cust_id) > 10
I don't have the expected output.
Thanks!
Upvotes: 0
Views: 1059
Reputation: 2492
Without seeing the expected output, I think what you have is right. If you want to see the total amount summed up, you would just need to add one more column to your query:
SELECT cust_id,
SUM(total_amt) AS Total_Amount_of_Transactions,
COUNT(cust_id) AS Count_of_Transactions
FROM Transactions
WHERE Qty >= 0
GROUP BY cust_id
HAVING COUNT(cust_id) > 10
Upvotes: 1