Here is the problem im trying to show Date and time for my selection, when i use the following code it shows the Date and time but leaves dups
SELECT DISTINCT(Item), OutDateTime_dt FROM Database Where AFTID_int = 2149 AND CID_int = 0 AND MID_int = 0 AND Item <> '' AND OutDateTime_dt >= '09/17/2003' AND OutDateTime_dt < '9/24/2003' Order by OutDateTime_dt Desc
However, if i remove the "OutDateTime_dt" from the first line,
leaving this
SELECT DISTINCT(Item) FROM Database
It removes the duplicates and works fine but doesnt give me the time as i need as well or date. Please help.If you only want one row per Item, and each Item may have many OutDateTime values, then you would have to choose which OutDateTime to display, e.g. the highest:
SELECT Item, MAX(OutDateTime_dt) FROM Database Where AFTID_int = 2149 AND CID_int = 0 AND MID_int = 0 AND Item <> '' AND OutDateTime_dt >= '09/17/2003' AND OutDateTime_dt < '9/24/2003' GROUP BY Item;
No comments:
Post a Comment