September 22, 2010 at 9:49 pm
Hello all!!! Newbie 1 Kanoobie here and I would like to say that installing SQL Server 2008 R2 on Windows 7 is a nightmare. I've had to downgrade to SQL 2005 but I'm noticing some of the SQL FUNCTIONS are not the same. Anyways Since I'm new at this and want to learn way more I am having a hard time installing 2008 on windows 7 any ideas? The issue is Server Management Tools will not install but everything else will.
Was also wondering if you know what this means:
Msg 8117, Level 16, State 1, Line 1:w00t:
Operand data type varchar is invalid for sum operator.
Here is the code:
SELECT LastName, SUM(EEO1Classification)
FROM EmployeeInformation
GROUP BY LastName
September 22, 2010 at 10:22 pm
seems like your column EEO1Classification is actually a varchar even though it might contain what seems to be just integers....so you'll have to explicitly convert it to do the sum instead:
Here is the code:
SELECT LastName, SUM(CONVERT(int,EEO1Classification))
FROM EmployeeInformation
GROUP BY LastName
if you get an error converting varchar to int, look at the data in the column...you might not be able to convert some values.
Lowell
September 22, 2010 at 10:28 pm
Lowell,
Thanks for the help so this is what happens when I try to input the data you gave me.
Code:
SELECT LastName, SUM(CONVERT(int, EEO1Classification))
FROM EmployeeInformation
GROUP BY LastName
Error:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Assistant Manager Officials & Managers' to data type int.
The other weird thing is that the Columns are set up as follows:
LastName (varchar(20), not null)
EEO1Classification (varchar(50), not null)
My next question is how do you know what the error code means because to me I can understand the code but when I get an error code I'm like well how come you don't offer a suggestion on how to fix SQL.. hehe
September 22, 2010 at 10:30 pm
:w00t:
September 22, 2010 at 10:36 pm
yep the errors telling you the issue, and it was kind of what i expected.
this value exists in that column:
'Assistant Manager Officials & Managers'
it should be obvious that string cannot be converted to an integer right? undoubtedly there are other values in the table that are strings of text...the hint is the column is varchar(50)....
maybe you want the COUNT of the values related to each last name, and not the sum of the values? that might make more sense.
SELECT LastName, COUNT( EEO1Classification)
FROM EmployeeInformation
GROUP BY LastName
that would return a lastname and how many times his name shows up with various EEO clasifications in that table.
Lowell
September 22, 2010 at 10:54 pm
Lowell,
You were totally right!!! 😀
You said,
it should be obvious that string cannot be converted to an integer right? undoubtedly there are other values in the table that are strings of text...the hint is the column is varchar(50)...."
So basically what this is saying is that I can not turn 'Assistant Manager Officials & Managers' into a number?
Here is the goal:
Select (display) employees’ last names and group them by EEO-1 classification.
Then
Select (display) employees’ last names and group them their job titles, grouped within exempt and non-exempt
Joe
September 22, 2010 at 11:02 pm
glad you are getting a handle on it; kudos for posting what you are trying so you can get the proepr kind of help; too often we see folks just paste their homework here and home for a guru to do it for them; of course they don't get any benefit out of that later, when they don't understand how to apply the concept.
finally,make sure you read your assignments requirement: i
Here is the goal:
Select (display) employees’ last names and group them by EEO-1 classification.
did you notice what your group by columns were? i think you need to look at that one more time; i don't see it asking for a count or a sum...maybe you need to change the group by you are trying?
Lowell
September 22, 2010 at 11:13 pm
Honestly, I'm not looking for the cheap way out I really want to learn this stuff and retain it. I would rather get a few hints like you have pointed out and try to make the mistakes on my own but when it comes to the error codes I try a couple of things then look for answers.
The whole thing is I'm not use to the error codes and what they mean. I think the error codes are a little more jargonyish and I have to learn how to dissect the meaning. You pickin up what I'm laying down?
Just to give you an idea.. this is now my 4th week in the class and I've never seen this before. However, I want to try and find a job doing this stuff it's really fun but I need to get waaaaayyyyy better. Especially at understanding the code; that's why I would rather do things on my own and learn from mistakes. After all that's what coding is... plus database manipulation.... Oh yea and 10% Geek and I'm only about 2%.. Don't worry I'm trying to figure out the next 8%...
Thanks for everything man your awesome.. I hope you don't mind me coming back for more when I get stuck...
Joe
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply