0

I'm struggling with a query. I'm trying to count how many item have actually renter a customer in a table with 1 line per rental. I want to filter the result to see just actual rental so I'm trying to filter by return_date=null but my result return all the entries instead of filtered ones.

Could you please give me a hint?

SELECT
    customer_no,
    rental_id,
    return_date,
    COUNT(IF(return_date = null, customer_no,null)) as ActualRental_per_person
FROM
    rental_table
GROUP BY
    member_no
;

Thanks in advance!

user3783243
  • 5,368
  • 5
  • 22
  • 41
  • 2
    Check this question: https://stackoverflow.com/questions/9581745/sql-is-null-and-null. You should use `return_date IS NULL` instead of `return_date = null` – AM14a Jun 15 '22 at 11:48

1 Answers1

0

try to do not use return_date = null. use return_date is null instead

Alessandro
  • 129
  • 1