Jump to content
  • 0

Sql Select Statment To Count Only Fields With Data


cpcbsa

Question

I Have tried to get support but they are not responding to my ticket and I have been struggling with this very simple task for a report. I need to create a calculated field that counts the number of fields with data in a column by district - do not count NULL fields. In normal SQL, you can use a count function which does not include NULL fields but this counts everything for some reason. Not sure what I am doing wrong but here is the statement which should pull the count of fields with data but instead counts all the fields by distrcit.. ANY help would be appreciated...

 

select count(Dropping_Unit) 
FROM CH_tbl_Base
WHERE District=[@field:DistrictName]
 
 
THANKS
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Just to update this post and add in the previous comment above, you may use CASE STATEMENT on this workflow:

CASE WHEN 

[@field:Dropping_Unit] != ' '

THEN

SELECT COUNT(Dropping_Unit) FROM CH_tbl_Base WHERE District= target.[@field:DistrictName]

ELSE

'Your other condition when the field has blank values'

END

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...