If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Removing Duplicates.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-03, 06:14
BiLLyD BiLLyD is offline
Registered User
 
Join Date: Sep 2003
Posts: 1
Removing Duplicates.

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.
Reply With Quote
  #2 (permalink)  
Old 09-22-03, 07:01
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Removing Duplicates.

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;
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On