• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 868
  • Last Modified:

Select all but one entries in a column of a table.

I have a table in SQL 2000: Man_Hours
It has 2 columns: Name, Hours
I have (say) 4 entries: Joe, Jane, Joane, Auto
Each of these entries has a 'Hours' associated with them.
I have to make a pie-chart with these values, but I don't want the Auto in my chart.
---------------------------
ID |   Name   | Hours  |
---------------------------
 1 |   Joe       |   20    |
 2 |   Jane     |   13    |
 3 |   Joane   |   22    |
 4 |   Auto     |   60    |
---------------------------
I need a query to select names and hours except Auto.
0
n4narik
Asked:
n4narik
  • 2
1 Solution
 
curtis591Commented:
select name , sum(hours)
from man_hours
where name <> 'Auto'
group by name
0
 
curtis591Commented:
Sorry I missed id
select id, name , sum(hours)
from man_hours
where name <> 'Auto'
group by id,name
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
SELECT Name, Sum(Hours) as myHours
FROM YourTableName
GROUP BY Name

This will add up all hours for these four names, with one record for each name.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now