I am using SQL to create a code that works for my database. I do not know how to
ID: 3809745 • Letter: I
Question
I am using SQL to create a code that works for my database. I do not know how to get this information using select statements and joins. Can someone help me with this please? I know there is not much information provided but a sample code of how it should be set up would be great. Thanks!!
Create a SELECT statement that calculates how many months Sam Chin was with the company.
Create a SELECT statement that calculates how many months Danial Din has been with the company. Concatenate the following to the result: “Daniel Din has worked for us for “ {insert results} “months.”
Create a SELECT statement that displays all employees and their Qualifications. Display that individuals with no Qualifications as having ‘NoQual’. Hint: to determine this ‘empty’ field using ISNULL
Using a calculated column, display Daniel Din's salary and his salary with a 10% raise. Display with a column alias for the new calculated column labelled 'Raise'.
What is the total number of employees who have Bachelors Degrees. Use the Count Function.
Display the employee’s last name, only the year value from each employee’s hire date, and their QUALDESC from the QUALIFICATION table.
Explanation / Answer
SELECT EMPID, EMPNAME, DEPARTMENT, DESIGNATION, convert(varchar(3),DATEDIFF(MONTH, DOJ, GETDATE())/12) +' years '+ convert(varchar(2),DATEDIFF(MONTH, DOJ, GETDATE()) % 12)+ ' months' AS EXPERIENCE, EMPSTATUS AS JOB_STATUS FROM EMPLOYEE WHERE EMPNAME="SAMCHIN"; SELECT EMPID, EMPNAME, DEPARTMENT, DESIGNATION, convert(varchar(3),DATEDIFF(MONTH, DOJ, GETDATE())/12) +' years '+ convert(varchar(2),DATEDIFF(MONTH, DOJ, GETDATE()) % 12)+ ' months' AS EXPERIENCE, EMPSTATUS AS JOB_STATUS FROM EMPLOYEE WHERE EMPNAME="DANIAL DIN"; SELECT e.FNAME + ' ' + e.LNAME AS [Employee Name], coalesce(q.QualDesc, 'NoQual') AS [Qualifications] FROM EMPLOYEE e left join QUALIFICATION q on e.QUALID = q.QUALID; UPDATE works w, manages m SET w.salary += salary * case where salary = salary+salary*0.10 AS RAISE AND w.employee-name = m.manager-name AND w.employee-name = ‘Danial Din’;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.