Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default prevent duplicate results (database query)

I'm using Excel's database query to get a list of accounts
(ACCTNAME) based on certain criteria (Like INN% and Like
MSS%). But, because INN and MSS occur multiple times
within the same account, Excel is returning those account
names multiple times. But I need (want) the account name
only once. Is there a "distinct" statement or some other
rule/criteria that I can build into the database query to
prevent the account name from appearing multiple times?
Here's the SQL statement from within MS Query (within
Excel):


SELECT ARACCT.ACCTNAME, ARACCT.SALES, ARACCT.ACCTSTAT,
ARACCT.CITY, ARACCT.STATE, ARACCT.OFFTELE,
ARACCT.IHPAYSTAT, ARACCT.IHPAYCMNT, ARTRAN.TRANCODE
FROM ihacct.dbo.ARACCT ARACCT, ihacct.dbo.ARTRAN ARTRAN
WHERE ARACCT.ARCODE = ARTRAN.ARCODE AND ((ARTRAN.TRANCODE
Like 'INN%') OR (ARTRAN.TRANCODE Like 'MSS%'))
ORDER BY ARACCT.ACCTNAME

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default prevent duplicate results (database query)

Interestingly enough you anwered your own question. After the work select in
the SQL add the work DISTINCT. if I correctly understand your question that
will work.

"Dan Wasser" wrote:

I'm using Excel's database query to get a list of accounts
(ACCTNAME) based on certain criteria (Like INN% and Like
MSS%). But, because INN and MSS occur multiple times
within the same account, Excel is returning those account
names multiple times. But I need (want) the account name
only once. Is there a "distinct" statement or some other
rule/criteria that I can build into the database query to
prevent the account name from appearing multiple times?
Here's the SQL statement from within MS Query (within
Excel):


SELECT ARACCT.ACCTNAME, ARACCT.SALES, ARACCT.ACCTSTAT,
ARACCT.CITY, ARACCT.STATE, ARACCT.OFFTELE,
ARACCT.IHPAYSTAT, ARACCT.IHPAYCMNT, ARTRAN.TRANCODE
FROM ihacct.dbo.ARACCT ARACCT, ihacct.dbo.ARTRAN ARTRAN
WHERE ARACCT.ARCODE = ARTRAN.ARCODE AND ((ARTRAN.TRANCODE
Like 'INN%') OR (ARTRAN.TRANCODE Like 'MSS%'))
ORDER BY ARACCT.ACCTNAME


  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default prevent duplicate results (database query)

Thanks, Jim! It worked perfectly.
Dan

-----Original Message-----
Interestingly enough you anwered your own question. After

the work select in
the SQL add the work DISTINCT. if I correctly understand

your question that
will work.

"Dan Wasser" wrote:

I'm using Excel's database query to get a list of

accounts
(ACCTNAME) based on certain criteria (Like INN% and

Like
MSS%). But, because INN and MSS occur multiple times
within the same account, Excel is returning those

account
names multiple times. But I need (want) the account

name
only once. Is there a "distinct" statement or some

other
rule/criteria that I can build into the database query

to
prevent the account name from appearing multiple

times?
Here's the SQL statement from within MS Query (within
Excel):


SELECT ARACCT.ACCTNAME, ARACCT.SALES, ARACCT.ACCTSTAT,
ARACCT.CITY, ARACCT.STATE, ARACCT.OFFTELE,
ARACCT.IHPAYSTAT, ARACCT.IHPAYCMNT, ARTRAN.TRANCODE
FROM ihacct.dbo.ARACCT ARACCT, ihacct.dbo.ARTRAN ARTRAN
WHERE ARACCT.ARCODE = ARTRAN.ARCODE AND

((ARTRAN.TRANCODE
Like 'INN%') OR (ARTRAN.TRANCODE Like 'MSS%'))
ORDER BY ARACCT.ACCTNAME


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import New Database Query (Union Query) in Spreadsheet klock Excel Discussion (Misc queries) 2 September 24th 09 01:30 AM
database query not showing foxpro database How I import data mangat New Users to Excel 1 June 24th 07 03:31 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
help in showing results of database query andy[_6_] Excel Programming 1 August 27th 04 08:47 AM


All times are GMT +1. The time now is 11:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"