Welcome Back

Google icon Sign in with Google
OR
I agree to abide by Pharmadaily Terms of Service and its Privacy Policy

Create Account

Google icon Sign up with Google
OR
By signing up, you agree to our Terms of Service and Privacy Policy
Instagram
youtube
Facebook

Retrieve Orders from the Last 30 Days in SQL

Retrieve Orders from the Last 30 Days in SQL

Orders Table:

Query Explanation:

● SELECT * → Retrieves all columns from the result.

● FROM Orders → The data is fetched from the Orders table.

● WHERE OrderDate >= CURDATE() - INTERVAL 30 DAY
→ Filters only the orders where the order date is within the last 30 days from today.
→ CURDATE() gives today’s date, and INTERVAL 30 DAY subtracts 30 days.


SQL Query:

USE SalesInventoryDB;

SELECT *  
FROM Orders  
WHERE OrderDate >= CURDATE() - INTERVAL 30 DAY;

 

Output: