MySQL Forums
Forum List  »  Newbie

Re: Get count(*) inside SELECT
Posted by: Peter Brawley
Date: October 02, 2020 10:03AM

Is this what you mean?

SELECT 
  customerID,
  SUM( If( notr=10,1,0) ) as invCount,
  SUM( Case WHEN notr = "10" THEN t1.value Else 0 End) invoiceValue,
  SUM( Distinct If( notr=16,1,0) ) as creditCount,
  SUM(Case WHEN notr = "16" THEN t1.value Else 0 End) creditValue
FROM table
GROUP BY customerID;

Options: ReplyQuote


Subject
Written By
Posted
October 02, 2020 05:11AM
October 02, 2020 05:31AM
Re: Get count(*) inside SELECT
October 02, 2020 10:03AM
October 05, 2020 02:34AM
October 05, 2020 03:36AM
October 29, 2020 06:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.