I have two tables, one is named Employee and the other Job_title. I'm trying to combine the two tables so I can group certain columns.
This is what I thought of so far and please correct me if I'm wrong.
SELECT Last_name FROM Employee
UNION
SELECT Job_title_code FROM Job_title
GROUP BY Exempt_non_exempt
FROM Job_title
Now this is just a theory (obviously it doesn't work) but basiclly I'm trying to have columns from two tables and have the grouped.Huh?
Wha?
There is no relationship between these tables?
No foreign keys?
You are selecting a single column and performing GROUP BY without any aggregate functions?
This makes no sense.|||Well, in both tables, they each have a job_title_code column.
Employee table
lastname, firstname, job title code
Job_title Table
job title code, job title, salary, exempt/non exempt|||Is this homework?
It looks like homework.
It sounds like homework.
Are we studying relational databases?|||So why aren't you using a join?
SELECT Last_name,
Job_title_code,
Exemp_non_exempt
FROM Employee
INNER JOIN Job_title on Employee.Job_title_code = Job_title.Job_title_code
I don't think this is homework. If it was homework his question would be more clearly phrased!|||sorry for the mix up, yes it is homework. that's for suggesting the INNER JOIN command. i found a variation of what you did and it worked out for my db. by the way, how did you put your code in a window like that?
SELECT Employee.Last_Name, Job_title.Exempt_non_exempt_status
FROM Employee
INNER JOIN Job_title
ON Employee.Job_title_code=Job_title.Job_title_code|||Enclose your code in CODE tagsL
[XCode]
Your code here
[X/Code]
Remove the X characters...
Your code here
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment