Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 how to omit dupplicate value from the table. ?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-06 : 09:45:23
Shoaib Khan writes "I am using Access as database
I have a table called employee which has departmentID,OfficeID in it.

"Select departmentID,department from department where cint(DepartmentID) = '"&dep&"'"

here dept = all the departmentID of employees of a certain Office

Here more then 2 employee have the same departmentID when I compare the value stored in a varible and in result I get more then 1 departmentID. I need a query in the above sql statment which will only show the departmentID once and skip the repeating of that ID. I have tried Descreat too but no use.

thanks
Shoaib Khan"

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2002-08-06 : 11:24:39
Not quite sure what your getting at but how about SELECT TOP 1 ...........

Paul
Go to Top of Page

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-08-07 : 08:03:39
If I understand you correctly, your results look something like this:

departmentID, department
1, Sales
2, Accounting
3, Marketing
1, Sales
2, Accounting

And you are wanting this:
departmentID, department
1, Sales
2, Accounting
3, Marketing

If this is a correct assumption, try the following:

"Select departmentID,department from department where cint(DepartmentID) = '"&dep&"' GROUP BY departmentID,department"

or

"Select DISTINCT departmentID,department from department where cint(DepartmentID) = '"&dep&"'"

I think the first one should be OK in Access. Not sure the second one will work in Access.

Jeremy



Edited by - joldham on 08/07/2002 08:05:27
Go to Top of Page
   

- Advertisement -