I'm working in Teradata SQL Assistant and I need to create a stored procedure that, given a table name, returns the percentage of NULL values for each column in that table.

Right now, I generate the entire query from Python, using a function where I pass the table name and the list of columns. It saves me some time, but it would be much better if I could do all of this directly in a stored procedure.

column_name null_percentage
col1 74
col2 32
.... ....

3 Replies 3

  1. You need to delete this question and ask a proper question... you're looking for an actual answer, not general advice (I know the UI is confusing, but unfortunately thats the way it is now).

  2. Why have you tagged SQL Server if you are using Teradata? They are completely different RDBMS.

  3. Ensure you provide a complete mre with full sample data and desired results, and the example of passing the table name and columns names.

  4. TERADATA SQL ASSISTANT is a client tool - its not especially relevant to your question which I take to be asking for SQL that runs against Teradata the RDBMS.

Note: You are expected to engage with commenters when asking a question on this site. Failure to engage makes it much less likely you'll receive a suitable answer.

I saw this question because of the sql-server tag. So I found a solution working there, see this db<>fiddle. This might help you get started, although it’s not for Teradata.

@JonasMetzler A count(v) skips nulls on its own, count(*) counts them: https://dbfiddle.uk/PS7sekql

Your Reply

By clicking “Post Your Reply”, 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.