My STOCK table is like this:
Catcode Item_No SoldOn Returned_Date Invoice_No
P P00797 9/19/2006 21/12/2005 COL01255
P P00798 8/20/2005 21/12/2005 COL01250
P P00799 6/10/2005 04/10/2006 COL01717
P P00799 5/13/2005 04/05/2006 COL01622
P P00800 2/09/2005 07/11/2005 COL01217
I would like retrieve distinct item_no (P00799) from the above table, so, I used the query as:
select Distinct A.Catcode,A.Item_No,A.SoldOn from Stock A where A.SoldOn in (select max(SoldOn) from Stock group by item_no)
which returns all the rows from the above table. (P00799 is coming twice)
(How can I modify the query to satisfy my condition)
Thanks in advance
Sql Duplicate Column
Moderator: General Moderators