MySQL Forums
Forum List  »  Newbie

Re: Querying 2 counts
Posted by: John Noble
Date: February 14, 2017 08:02AM

Think I got it working now.

select CONCAT(year(invoiceDate), " ", MONTHNAME(STR_TO_DATE(month(invoiceDate), '%m'))) as yrmnth,
sum(case when docType = 'Inv' and countryID = p_countryID and invoiceDate BETWEEN p_fromDate and p_toDate then 1 else 0 end) invCount,
sum(case when docType = 'Crd' and countryID = p_countryID and invoiceDate BETWEEN p_fromDate and p_toDate then 1 else 0 end) CreditCount
from salesLedger WHERE invoiceDate BETWEEN p_fromDate and p_toDate
group by year(invoiceDate), month(invoiceDate);

Options: ReplyQuote


Subject
Written By
Posted
February 14, 2017 04:49AM
Re: Querying 2 counts
February 14, 2017 08:02AM
February 20, 2017 04:32AM


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.