I need to write a select statement I am unsure how to do this correctly. My psuedo code would be,
IF first_gift_date <> NULL THEN COUNT(item_id). However, the item_id must be distinct.
I tried the following:
SELECT
COUNT(CASE WHEN first_gift_date <> NULL THEN (DISTINCT item_id) end)
FROM table_a
adding DISTINCT does not work and I am unsure how to get a distinct count using a case expression.
IF first_gift_date <> NULL THEN COUNT(item_id). However, the item_id must be distinct.
I tried the following:
SELECT
COUNT(CASE WHEN first_gift_date <> NULL THEN (DISTINCT item_id) end)
FROM table_a
adding DISTINCT does not work and I am unsure how to get a distinct count using a case expression.