Ridgejp
asked on
Select Results on a Rolling Time Period
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you provide some sample data and expected result?
ASKER
This is the code I was looking for, which produces a 21 rolling day view: -
WHERE invoiceDate >= now() - INTERVAL 21 DAY
WHERE invoiceDate >= now() - INTERVAL 21 DAY
ASKER
Thanks for the prompt made me realise I knew enough to work it out!
ASKER
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