Write a SOQL query to fetch all Opportunities created in the Last 30 Days whose StageName is not Closed Lost.
Answer
Combine the LAST_N_DAYS date literal with a stage filter.
soql
SELECT Id, Name, StageName, CreatedDate FROM Opportunity
WHERE CreatedDate = LAST_N_DAYS:30 AND StageName != 'Closed Lost'
Date literals avoid hardcoded dates, so the query stays valid every day.
soqlscenariodate-literals