Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 5th, 2011, 10:33 PM
Authorized User
Points: 247, Level: 4
Points: 247, Level: 4 Points: 247, Level: 4 Points: 247, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2006
Location: Stone, California, Malaysia.
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Loop

Morning and hi all,

Refer to code below how should I loop using for loop : -

SELECT
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -10 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -09 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -09 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -08 DAY) THEN 'Resolved' END ) AS 'DAY -10',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -09 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -08 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -08 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -07 DAY) THEN 'Resolved' END ) AS 'DAY -09',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -08 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -07 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -07 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -06 DAY) THEN 'Resolved' END ) AS 'DAY -08',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -07 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -06 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -06 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -05 DAY) THEN 'Resolved' END ) AS 'DAY -07',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -06 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -05 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -05 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -04 DAY) THEN 'Resolved' END ) AS 'DAY -06',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -05 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -04 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -04 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -03 DAY) THEN 'Resolved' END ) AS 'DAY -05',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -04 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -03 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -03 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -02 DAY) THEN 'Resolved' END ) AS 'DAY -04',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -03 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -02 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -02 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL -01 DAY) THEN 'Resolved' END ) AS 'DAY -03',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -02 DAY) AND date_submitted < DATE_ADD( CURDATE(), INTERVAL -01 DAY) AND last_updated > DATE_ADD( CURDATE(), INTERVAL -01 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL 00 DAY) THEN 'Resolved' END ) AS 'DAY -02',
COUNT(CASE WHEN date_submitted > DATE_ADD( CURDATE(), INTERVAL -01 DAY) AND date_submitted < CURDATE() AND last_updated > DATE_ADD( CURDATE(), INTERVAL 00 DAY) AND last_updated < DATE_ADD( CURDATE(), INTERVAL 01 DAY) THEN 'Resolved' END ) AS 'DAY -01'
FROM my_basket
WHERE status >= 80


Tq...
Reply With Quote
  #2 (permalink)  
Old October 8th, 2011, 07:35 PM
Authorized User
Points: 247, Level: 4
Points: 247, Level: 4 Points: 247, Level: 4 Points: 247, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2006
Location: Stone, California, Malaysia.
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anybody help ?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop twice, then inside loop select nodes?? JohnBampton XSLT 2 March 9th, 2009 05:21 AM
"DO" loop enolregnar VB How-To 8 June 8th, 2007 12:54 AM
loop crmpicco Classic ASP Basics 1 February 12th, 2005 08:12 PM
Do Loop junemo Beginning PHP 8 July 28th, 2004 02:58 AM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 07:46 AM



All times are GMT -4. The time now is 09:56 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.