Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2005, 07:28 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Distinct values of data

Hi everyone,

I need help in finding distinct values of data from a table. I have a table that has 3 columns or fields memName1,memName2,memName3 which contains multiple names separated by ",".I now want to obtain the distinct names that appear in these columns into one single column.

I am not able to construct a proper sql query. Can anyone help me with this??

Thanks in advance
 
Old September 6th, 2005, 07:37 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What do you mean? Do you want to concatenate the columns like "memName1, memName2, memName3" or do you want to split out the date like this:

FROM:
memName1
FirstData, SecondData, thirdData

TO:
NewColumn
FirstData
SecondData
ThirdData
etc.



mmcdonal
 
Old September 6th, 2005, 07:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, split out the data, not the date.

mmcdonal
 
Old September 6th, 2005, 07:43 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Or, like this...

FROM:
memName1
FirstData, SecondData, thirdData

TO:
New Column1 NewColumn2 NewColumn3
FirstData SecondData ThirdData



mmcdonal
 
Old September 6th, 2005, 07:47 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First of all I want concatenate the values in memName1,memName2,memName3 then when I get a composite value I want to obtain the distinct names in to another column or variable.

from:
memName1,memName2,memName3

to
New Column
 
Old September 6th, 2005, 09:28 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What is the starting format, and the ending format? Please use sample data.


mmcdonal
 
Old September 8th, 2005, 02:22 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well I am giving some sample data as below:


memName1:

Shekhar Mehta
Aniruddh Daga
Aniruddh Daga, Nisheeth Totla
Virendra Singhvi
Raakesh Jain
Pradeep Tibrewal

memName2:

Naresh Kumar Jalan
Shekhar Mehta
Shekhar Mehta
Raj Somani
Sunil Poddar

memName3:

Vinay Agarwal
Deepak Choudhary, Raghupati Bhuwalka
Sanjay Bagaria
Raghupati Bhuwalka, Ramesh Khaitan
Nathmal Neotia, Ram Pal Widhawan, S Chiraniwala
Mahesh Shah, Padam Agarwal, Sanjay Bagaria
Sunil Poddar

I need a query which will return me the distinct names only into one column or as one single dataset that appear in the 3 columns memName1,memName2,memName3.

the columns memName1,memName2,memName3 are text fields and the return column also has to be a text field.



It will be great if such a query can be constructed.
Thanks
 
Old September 8th, 2005, 02:37 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

So, using the first value in each field, your new column should look like:

Shekhar, Mehta Naresh Kumar Jalan, Vinay Agarwal

Is this correct?

Kevin


dartcoach
 
Old September 8th, 2005, 02:42 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My new column should have each single name as a single row value and names will not be separated by commas and not repeated i.e distinct rows only
 
Old September 8th, 2005, 02:45 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Could you give me an example of what you want the data to look like?

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting distinct sibling values from a key Chris Cash XSLT 2 June 19th, 2006 05:03 PM
getting distinct values from attribute markus2000 XSLT 1 June 13th, 2006 03:06 AM
count distinct values Chris Cash XSLT 3 June 8th, 2006 04:55 PM
distinct-values in Javascript Jan1 XML 2 October 10th, 2005 04:56 AM
DISTINCT ntext Values fleming SQL Server 2000 2 July 23rd, 2005 06:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.