Medium SQL Challenge: Failed Attempt

365 Days of Daily Coding: Day 55

I have been fairly busy with work these days and so I am much occupied with troubleshooting issues and coming up with a solution. Therefore, I haven’t had enough time to look into other personal areas of my life. I hope there’s going to be some brakes.

Today, I was trying to solve a medium sql challenge in sqlpad. Unfortunately, I haven’t been able to come up with a solution. The following is what I have so far:

WITH newrental AS (
  SELECT * FROM rental 
  WHERE DATE(rental_ts) 
  BETWEEN '2020-05-01' AND '2020=05-31'), 
  temp AS(
	SELECT c.customer_id, r.rental_id, r.rental_ts
	FROM customer c LEFT JOIN newrental r
	ON c.customer_id = r.customer_id),
	cases AS(
	  SELECT customer_id,
	  CASE WHEN rental_id IS NOT NULL THEN 'rented'
	  ELSE 'never-rented' 
	  END hass_rented
	  FROM temp
	  )

I will continue to work on this tomorrow.

Leave a comment