Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Distinct Count Error

$
0
0
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.

Viewing all articles
Browse latest Browse all 13329

Trending Articles