Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Issues 1

Status
Not open for further replies.

UncleHuckleberry

Technical User
Dec 4, 2003
58
GB
I am trying to write a query where a the ID could have more than one category e.g.

ID Category
-- -----------------
1 Category 1
2 Category 2
3 Category 1
4 Category 2

Etc...

What I would like to do is if there is more than one category for an ID select only one of them to eliminate multiple rows for the same id. Whats the best way to do this? Thanks.
 
Your example doesn't have more than one category for an ID. Did you mean something like
[tt]
ID Category
-- -----------------
1 Category 1
1 Category 2
2 Category 1
2 Category 2
[/tt]?
If so, try some SQL like
[tt]
Select ID, MAX(Category) As MaxCategory
From tbl
Group By ID
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top