We help IT Professionals succeed at work.

Select Results on a Rolling Time Period

Ridgejp
Ridgejp asked
on
77 Views
Last Modified: 2017-03-17
Hi,

I'm using PHP/MySQL to return data sets on a daily basis.

But what's the WHERE clause statement to extract results from a SELECT query perhaps on a rolling weekly, monthly or quarterly basis?

I'm asking so that the Select query returns a constant moving set of results set based on the data found in the database.

Jason
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Hi,

Yes so a typical query might look like: -

SELECT orderID, buyerName, BuyerAddress1, BuyerAddress2, BuyerAddress3, buyerCounty, buyerPCD, catID, quantity, totalPrice FROM salesuk WHERE invoiceDate >= "01/01/2017" ORDER BY DESC;

That type of query ... hope that helps?

J
Sharath SData Engineer
CERTIFIED EXPERT

Commented:
Can you provide some sample data and expected result?

Author

Commented:
This is the code I was looking for, which produces a 21 rolling day view: -

WHERE invoiceDate >= now() - INTERVAL 21 DAY

Author

Commented:
Thanks for the prompt made me realise I knew enough to work it out!