Create a query that will replace the null for termdate in the workers table with
ID: 3684974 • Letter: C
Question
Create a query that will replace the null for termdate in the workers table with the text 'Current Employee'. Include in your output the people id, hire date and term date. Rename the term date column to Current. Order your output so that the current employees show at the top. Hint: This query can be solved a number of ways. If you try to use COALESEQ only, you will get an error. The function COALESCEQ, will look for nulls and replace with text. Since the term date field is not a text field you will need to convert it to a text field before using COALSCE(). My output looked like the following:Explanation / Answer
Answer:
Perform These Two Queries One After The Other To Get The Output :
1)Converting the column termdate value to null.
SELECT
TERMDATE as DATE
CONVERT(date, NULL) as CURRENT
FROM WORKERS
2)Search for null values and replace with string 'Current Employee'
SELECT people id,hire date,termdate COALESCE([termdate],'Current Employee') FROM WORKERS ORDER BY termdate DESC
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.