Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to use "distinct" to prevent duplicate records
I'm using MS Query within Excel to extract mailing addresses from my SQL
database (based on total dollars spent). See the Query, below. I'm getting duplicate addresses because there are multiple records for the same address. I don't want to send multiple letters to the same address so I want to prevent duplicate addresses. But no matter where I place the word "distinct," I get an error message (in Query): "could not add the table." Names and addresses are held in a table called IINFO. Street addresses are in the field called I_ADDR1 within the IINFO table. Any suggestions on how to prevent duplicate street addresses? (BTW ... I previously posted this question to the group but it never appeared ... maybe I didn't wait long enough ... sorry if this is a duplicate question.) Thanks. Dan SELECT Sum(STAY.S_TOTSPENT), IINFO.I_FIRST, IINFO.I_LASTNAME, IINFO.I_ADDR1, IINFO.I_CITY, IINFO.I_STATE, IINFO.I_ZIP FROM (IINFO LEFT JOIN STAY ON STAY.S_IRECID = IINFO.I_RECID) WHERE STAY.S_STATUS = 'HIST' AND STAY.S_ADATE = CONVERT(DateTime,'11/14/2004 00:00:00',101) AND IINFO.I_FIRST Not Like 'Group Master' AND IINFO.I_ADDR1 '1' GROUP BY IINFO.I_FIRST, IINFO.I_LASTNAME, IINFO.I_ADDR1, IINFO.I_CITY, IINFO.I_STATE, IINFO.I_ZIP ORDER BY IINFO.I_ADDR1 ASC |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Prevent Duplicate Records | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
In Excel 2003 is there a way to prevent "Save As" and "Print"? | Excel Discussion (Misc queries) | |||
Excel should let me eliminate "duplicate records" in a column | Excel Discussion (Misc queries) | |||
Can you "duplicate" "copy" listboxes and code to multiple cells? | Excel Programming |