Sunday 15 August 2010

mysql - Retrieving Data from database on quaterly basis condition But it should be based on current year data only -


I tried this code:

Its work is also fine, but the problem is, if The current month is Feb and I urge this query to accept it since the last 3 months and hence starts from the last year i.e. 2012 neo or dc says that i just want data for the current year, if this is fame And if I set this query to fire, then it only lives and Faab Records. SELECT CROEmailId (SELECT CROEmailId) from LEADStatus, where SELECT COUNT (LeadId) date (`leadtime`)> DATE_SUB (now (), INTERVAL 3 months) and generated = 1 and assigned = As a 'new lead'), (select Leedildeld for where the date (updated)> DATE_SUB (now () (for 3 months) and assigned = A. ChromaIlid). As Lead Update ", (where did the mailboxes from SELECTSAM (Total Emails) date (completed) & gt; DATE_SUB (now () (interval 3 months) and mailform = A.Co.mail ID), as 'Email Uploaded', (Select SUM (Total Sent) Mailboxes Date (Completed)> DATE_SUB (Now (), INTERVAL 3 months) and mailform = a.CROEmailId. 'Email sent', (SELECT SUM (NetTotal) from invoice where payment is given to 'Pay' from Status Winner & Date (Created) & gt; DATE_SUB (now () (INTERNAL, 3 months) and CROEmailId = a.CROEmailId) As of today;

Try the change

  DATE_SUB (now (), Interval 3 months)   

to

  IF (month (kurt ()) <4, dATE_FORMAT (curate), '% Y-01 -01 '), Curtat () - Interval 3 months)   

In all subqueries.

  Select CROEmailId, (SELECT COUNT (LeadId) from LeadStatus WHERE Date (`Leadime`)> If (Month (Curate ()) <4, DATE_FORMAT (Curate ( ), '% Y-01-01'), Kurt (- INTERVAL 3 months) and generated = 1 and specified = A.CROEmailId) in the form of 'new lead', (SELECT COUNT (Lead) from LeadEd where date Done)> IF (MONTH (CURDATE ()) <4, DATE_FORMAT (CURDATE (), '% Y-01- 01'), Curtid () - interval 3 months) and 'appointed AC. 'Lead updated' in the form of 'Crimail IDID', (Selame Amel) Mailzbus Date ( (Month (Curate ()) <4, DATE_FORMAT (CURDATE (), '% Y-01-01'), CURDATE () - INTERVAL 3 months) and MailFrom = a.CROEmailId) As the email has been uploaded, (SELECT SUM (TotalSent) from MailJobs where the date (full)> if (email ("email sent") (month (string () (4), DATE_FORMAT ( CURDATE (), '% Y-01-01'), CURDATE () - INTERVAL 3 months) and mailform = A.CROEmailId (, select the challan (netlot) status = 'paid' and date (generated import)> If (month (curate ()) & lt; 4, DATE_FORMAT ('Curate', '% Y-01-01'), Kurt () - Interval 3 months) and 'payment today' as a 'CROEmailId' client manager;    

No comments:

Post a Comment