G. You are interested who has volunteered in the last 6 weeks. Write a query tha
ID: 3890184 • Letter: G
Question
G. You are interested who has volunteered in the last 6 weeks. Write a query that returns the volunteer's last name, company, organization he/she volunteered with, and the date of the volunteer activity. Your query should only show results within 6 weeks of the current date. Sort by the volunteer date (most recent), then last name. Your output (if it was run on 2 OCT 17) should look like the result below last name company id organization Amon Cabiness A2 Minns Rock Amon Cabiness A2 Rock Baoo Booher teer date 2017-09-19 2017-09-19 2017-09-19 2017-09-19 2017-09-12 2017-09-12 2017-09-12 2017-09-10 2017-09-10 83 Paws for Cause Paws for Cause Paws for Cause Paws for Cause Paws for Cause Paws for Cause Paws for Cause Unified Soorts Unified Soorts F2 G3 83 G3 12 A2Explanation / Answer
Please find the query below :
SELECT
v.last_name,
v.company_id,
vh.organization,
vh.volunteer_date
FROM
volunteer v,
volunteer_hours vh
WHERE
v.xnumber = vh.volunteer_xnumber
vh.volunteer_date >= DATEADD(WEEK, -6, GETDATE())
ORDER BY
vh.volunteer_date DESC,
v.last_name
In above query, first condition is for joining volunteer with volunteer_hours and second condition is for checking the date is withing 6 weeks or not.
Please let me know if you face any issue understand the query
Please vote up if satisfied.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.