Hi I am new to Oracle. How do I do a simple statement, for example get product id from the last 30, or 20 days purchase date?
SELECT productid FROM product WHERE purchase_date ?
Here's the SQL query to get records from last 7 days in MySQL. In the above query we select those records where order_date falls after a past interval of 7 days. We use system function now() to get the latest datetime value, and INTERVAL clause to calculate a date 7 days in the past.
If you would like to subtract dates or times in SQL Server, use the DATEADD() function. It takes three arguments. The first argument is the date/time unit – in our example, we specify the day unit. Next is the date or time unit value.
SELECT productid FROM product WHERE purchase_date > sysdate-30
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With