0

I have a table with ID, data 1, and few other columns... data 1 has NA as well.

I need to find a distinct ID, followed by the total count of each ID and the count for each ID whose data has NA. I need to determine how much of NA values are loaded for each ID.

Thanks Sai

2 Answers 2

3
select 
  id,
  count(*) as total_count,
  count(*) filter (where data1 = 'NA') as na_count
from _table 
group by id;
Sign up to request clarification or add additional context in comments.

Comments

1

You can use standard sql with conditional aggregation as follows:

Select id, count(1) as total,
       Count(case when data1='NA' then 1 end) as NA_count
  From your_table
Group by id;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.