Connecting Tech Pros Worldwide Forums | Help | Site Map

Query with Quarter !!!!

Member
 
Join Date: Feb 2009
Posts: 57
#1: Oct 5 '09
Hi Guys,
I have a query to write which will return the sum of amounts for different quarters in a year.But the problem is, the financial year may start from any of the months, not necessarily from Jan always.

I have already written the query for finding these amounts if the financial year starts from January. Can anyone please help me to achieve this?

Thanks in advance,
Lauren

dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,095
#2: Oct 5 '09

re: Query with Quarter !!!!


Post your query.



Dan
Member
 
Join Date: Feb 2009
Posts: 57
#3: Oct 6 '09

re: Query with Quarter !!!!


I have written the following query for retrieving sum of amounts based on quarter if the financial year starts with Jan:-

Expand|Select|Wrap|Line Numbers
  1. SELECT  SUM(MSB.NetQnty) Total 
  2. FROM
  3.     MSA
  4. INNER JOIN 
  5.     MSB
  6. ON 
  7.     MSA.ID = MSB.RefID
  8. WHERE
  9.     MSA.Anchor_ID = intAnchorID
  10. AND 
  11. MSA.Org_ID = intOrgInstance
  12. AND
  13. MSA.InvoiceDate >= DATE_SUB(CURDATE(),INTERVAL 4 QUARTER)
  14. AND 
  15. MSA.InvoiceDate <= CURDATE()
  16. AND
  17. MSA.RecordStatus = 1
  18. AND
  19. MSB.RecordStatus = 1
  20. GROUP BY QUARTER(MSA.InvoiceDate);
Thanks,
Lauren
Member
 
Join Date: Feb 2009
Posts: 57
#4: Oct 9 '09

re: Query with Quarter !!!!


I worte a customized Quarter function which will take care of the financial year issue.

Thanks,
Lauren
Reply