I have been working on this practice problem for SQL class for the past 30 minutes. I am having a hard time including rows that have NULL values in it or a numerical value of 0. I will post the question and then the query that I have written:
"Write a query to display the tour name, outing date, and number of registered clients for each outing of that tour on each date. Include only outings that were scheduled to occur after October 27, 2013. Include tours with no outings and outings with no registered clients. Sort the result by the number of clients in descending order, and then by outing date in ascending order."
SELECT TOUR_NAME,OUT_DATE,Count(DISTINCT CLIENT_NUM) AS "Num Clients"
FROM TOUR RIGHT JOIN OUTING USING (TOUR_ID) JOIN REGISTER USING (OUT_ID)
WHERE To_Char(OUT_DATE,'YYYY-MM-DD') > '2013-10-27'
GROUP BY TOUR_NAME,OUT_DATE
ORDER BY "Num Clients" DESC,OUT_DATE;
I cannot figure out how to pull rows with empty cells. It currently only pulls complete rows.
-EXPECTED RESULTS: --TOUR_NAME --OUT_DATE --Num Clients
Weekend Weekday 29-OCT-13 26 Downtown 28-OCT-13 25 Deluxe Day Away 28-OCT-13 23 Quick Break 30-OCT-13 19 Downtown 27-OCT-13 18 Downtown 30-OCT-13 18 Deluxe Day Away 31-OCT-13 12 Washington Heights 31-OCT-13 10 Weekend Weekday 13-NOV-13 0 Downtown 14-NOV-13 0 Beltway 15-NOV-13 0 Weekend Weekday 15-NOV-13 0 Quick Break 16-NOV-13 0 Power Shots 0 Perfect Endings 0 Primary Point 0
MY ACTUAL RESULTS: TOUR_NAME OUT_DATE Num Clients Weekend Weekday 29-OCT-13 26 Downtown 28-OCT-13 25 Deluxe Day Away 28-OCT-13 23 Quick Break 30-OCT-13 19 Downtown 27-OCT-13 18 Downtown 30-OCT-13 18 Deluxe Day Away 31-OCT-13 12 Washington Heights 31-OCT-13 10
It's not including any rows that has a null value or a zero count value within that row.
I appreciate any help. Thank you.