Finding Last Seven Days Data
This explanation about Oracle SQL Query:
Generally most of the people confuse here is how to handle NULL values.
so, here I am going to show you how we can do this.
I am taking Sales Date and replacing NVL with SYSDATE means it treats like this is the Max or today date greater than or equal to SYSDATE-7 means seven days back date (ex 2017-11-4 - 7 days: 2017-10-29)
Query:
SELECT * FROM Tbl_Daily_Sales WHERE NVL(Sale_Date,SYSDATE) >= (SYSDATE-7);
Please find below Output:
How to Delete Duplicate Rows In Below Scenario
I have a sample data where the ID is unique, but there are multiple duplicate rows(excluding ID). The other columns are Name, Age, DOB, Transaction Date, Payment, Amount. I have purposely duplicated few rows, and kept ID unique.
--Deleting Duplicate
;WITH Cte AS (SELECT ID,Name, Age, DOB, Transaction_Date, Payment, Amount, ROW_NUMBER() OVER(PARTITION BY Name, Age, DOB, Transaction_Date, Payment, Amount ORDER BY ID) Seq FROM #Temp) DELETE FROM Cte WHERE Seq<>1
Please Give Your Comments and Ask Some Questions:
Subscribe to:
Posts (Atom)