Gossamer Forum
Home : General : Databases and SQL :

sql query question

Quote Reply
sql query question
Hello everyone. I have tried to figure this SQL query out for a while but couldn't get it to work. Basically, I have the following data from vehicle 5OEC140 w/ 2 columns

Tire_Position
LF
LF
RF
RR

Tire_number
1
2
3
4

I tried to write an SQL query that would add the total of tire_number. So the answer would be 10, but all I got is 4. Here's my query

Select Count(Tire_Number) Total
From Tire
Where License_Number = '5OEC140';

Please advise what I did wrong. Thanks a lot guys. Ryan
Quote Reply
Re: [hdnguyen3] sql query question In reply to
You need to use sum(Tire_Number).
Count(Tire_Number) will count the number of rows which is 4.

Bob
http://totallyfreeads.com.au
Quote Reply
Re: [lanerj] sql query question In reply to
thanks for replying.. i tried sum before and it said 'wrong datatype in operand'...that's why i'm confused.. please advise what to do..thanks
Quote Reply
Re: [hdnguyen3] sql query question In reply to
SELECT SUM(Tire_number) WHERE License_Number = '5OEC140'

...should be fine.
Quote Reply
Re: [Paul] sql query question In reply to
thank guys