SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL express version


SQL express version

Author
Message
stephie.koen
stephie.koen
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 7
Hi Guys,

I know I might be in the wrong topic group but I am new here and don't know how to use it.

I am currently doing sql at UNISA and I have an sql assignment question that I don't know how to complete.

The question reads as follows:

The HR department wants to get a list of underpaid employees, salary history of employees and the salary history of managers based on an industry salary survey.
You were requested to create a SQL statement (save it as A2Q10) to do the following:
Retrieve the details of the employee ID, hire date and manager ID of those employees whose mangers are 101, 102, 103 and 108 and who is in the IT department.
If the salary is less than a certain AMOUNT (request the user to dynamically insert this value),
o insert the details of employee ID and salary into the SPECIAL_SAL table.
o Insert the details of employee ID, hire date and salary into the SAL_HISTORY table.
o Insert the details of employee ID, manager ID and salary into the MGR_HISTORY table.

I know how to retrieve the data but I don't know how to insert the specific data into those tables.

I know how to insert new data in a table, but don't know how to combine it.

PLEASE HELP...... question counts like 15 marks.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86240 Visits: 45232
I'm not going to do your homework for you. You learn nothing, I don't need the practice and I'm sure your lecturer doesn't condone other people doing your work for you either (I'm also studying at UNISA, I'm pretty sure I know the person who teaches that course)

What have you got so far?
Where exactly are you stuck?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


stephie.koen
stephie.koen
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 7
well what I have is the following:

the code for retrieving the data:

SELECT e.employee_id, hire_date, e.manager_id, e.salary
FROM employees e JOIN departments d
ON e.department_id = d.department_id
WHERE d.department_name = 'IT'
AND e.manager_id IN (101, 102, 103, 108)

now the part I am stuck at is this:
If the salary is less than a certain AMOUNT (request the user to dynamically insert this value),
o insert the details of employee ID and salary into the SPECIAL_SAL table.
o Insert the details of employee ID, hire date and salary into the SAL_HISTORY table.
o Insert the details of employee ID, manager ID and salary into the MGR_HISTORY table.

if I run the part that I have it all works fine, but I don't know how to combine that to insert data in a table if my salary is say like less than 6000
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86240 Visits: 45232
First things first, take that query you already have and figure out how to have it only return rows for salary under a specific value (which from the reading I would assume would be a variable)

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


stephie.koen
stephie.koen
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 7
can you use a CASE statement with this question?

it looks like it can but at the other end it also looks like it cant
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86240 Visits: 45232
You don't need a case statement here.

Take the query you posted, figure out how to have that query only return salary values that match the requirement.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search