Hi guys,
This time our task is to remove or eliminate duplicate entries from a sql Table.
Consider we have a Table Say Employee which contain some duplicate entries,and we have to eliminate the duplicate ones.
So lets start thinking..
Declare @MaxValue int Select @MaxValue=(case when @MaxValue>Amount then @MaxValue else Amount end) From T1 Select @MaxvalueInterviewer impressed by this, but he still wanted the output, i.e, the max value using a single query.
Declare @MaxValue int Select @MaxValue=Amount From T1 Group by Amount Select @MaxValueI was ok with the query,because the desired result was there...and then i put the same condition whcih was put by interviewer in my case,i.e i need the result in single query..
SELECT T11.Id, T11.Amount as MaxAmount FROM T1 AS T11 left outER JOIN T1 AS T12 ON T11.Amount < T12.Amount GROUP BY T11.Amount, T11.Id having COUNT(T12.Amount)=0
My Dear readers, I am really thankful for being supportive all these years. This site was the first blog site I ever created in my life...