• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 862
  • 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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