September 27, 2010 at 9:38 pm
Hello All,
I'm suck and would like to know if there is a way to query one table but have the data Grouped by the name of a column in another table?
Here is my code:
SELECT Max(Salary)
FROM EmployeeInformation
GROUP BY ExemptNonExemptStatus
EmployeeInformation is one Table and ExemptNonExemptStatus is a column from JobTitle Table.
Salary is a column from EmployeeInformation
Basically I want to take the Max Salary data from the EmployeeInformation Table and organize the Max salary by the ExemptNonExemptStatus data.
September 27, 2010 at 10:08 pm
You can , but only when u have a JOIN clause on the JobTitle table..
September 27, 2010 at 10:11 pm
Sure, it is possible you just have to JOIN the two tables in the FROM clause.
Not having the table structures makes it so I can't actually write it for you. Here is an article that can help you submit better questions that would allow people to more easily help you: http://www.sqlservercentral.com/articles/Best+Practices/61537/
Essentially it would look something like this:
SELECT
JT.ExemptNonExemptStatus,
Max(EI.Salary)
FROM EmployeeInformation EI
INNER JOIN JobTitle JT
ON EI.<column name> = JT.<column name>
GROUP BY
JT.ExemptNonExemptStatus;
September 27, 2010 at 10:42 pm
Thank you for the help however, when I apply these changes it gives me an error saying:
Msg 235, Level 16, State 0, Line 1
Cannot convert a char value to money. The char value has incorrect syntax.
September 27, 2010 at 10:45 pm
Can you at least share the query you were running that gave you the error?
You might want to review the article that I linked to in my previous post. With the information we have right now there is nothing more that we can do to help.
September 27, 2010 at 10:51 pm
I'm taking a guess here, but I suspect you are using the wrong columns in the ON clause to join the two tables. What columns link the two tables?
September 29, 2010 at 10:13 pm
Did you get this problem resolved?
If not, can you provide us with the table structures so we can try to help?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply