Home » SQL & PL/SQL » SQL & PL/SQL » not null column count (merged 2)
not null column count (merged 2) [message #317276] Wed, 30 April 2008 05:58 Go to next message
saiphani723
Messages: 38
Registered: July 2006
Location: Hyderabad
Member
can anybody tell how to count a NOT NULL columns in a table for each row.

Re: NOT NULL columns count [message #317282 is a reply to message #317276] Wed, 30 April 2008 06:27 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
This is NOT an expert question.

It is clearly stated in the forum description: "Newbies should not post to this forum!"
Expert notion is defined in the sticky: Not an EXPERT? Post in the NEWBIES forum, NOT here
Rules are described in: OraFAQ Forum Guide
Read them, follow them including what is said about formatting.

As you are an expert, I don't answer the question because you obviously already knows it.

Regards
Michel
Re: NOT NULL columns count [message #317287 is a reply to message #317276] Wed, 30 April 2008 06:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use COUNT.

Regards
Michel
Re: NOT NULL columns count [message #317290 is a reply to message #317276] Wed, 30 April 2008 06:38 Go to previous messageGo to next message
saiphani723
Messages: 38
Registered: July 2006
Location: Hyderabad
Member
Dear Michel,

using COUNT we can know how not null values for particular column.

i will explain my scenario


/forum/fa/4207/0/
  • Attachment: scenario.jpg
    (Size: 31.58KB, Downloaded 694 times)
Re: NOT NULL columns count [message #317299 is a reply to message #317290] Wed, 30 April 2008 07:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use COUNT and CASE/DECODE/NVL2

Regards
Michel
Re: NOT NULL columns count [message #317337 is a reply to message #317299] Wed, 30 April 2008 11:43 Go to previous messageGo to next message
saiphani723
Messages: 38
Registered: July 2006
Location: Hyderabad
Member
using COUNT and DECODE/CASE/NVL2 i am not getting

can u pls tell me how to proceed.
Re: NOT NULL columns count [message #317338 is a reply to message #317337] Wed, 30 April 2008 12:16 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Post what you tried.

Regards
Michel
Re: NOT NULL columns count [message #317341 is a reply to message #317338] Wed, 30 April 2008 14:08 Go to previous messageGo to next message
saiphani723
Messages: 38
Registered: July 2006
Location: Hyderabad
Member
i tried in the following way

my screen capturing is not working. becuase of that i copied and paste hee

SQL> select nvl2(empno,1,0)+nvl2(ename,1,0)+nvl2(job,1,0)+nvl2(sal,1,0)+nvl2(comm,1,0)+nvl2(deptno,1
,0) from emp;

NVL2(EMPNO,1,0)+NVL2(ENAME,1,0)+NVL2(JOB,1,0)+NVL2(SAL,1,0)+NVL2(COMM,1,0)+NVL2(DEPTNO,1,0)
-------------------------------------------------------------------------------------------
5
6
6
5
6
5
5
5
5
6
5
5
5
5

14 rows selected.
Re: NOT NULL columns count [message #317342 is a reply to message #317341] Wed, 30 April 2008 14:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And is this not the correct result?

Regards
Michel
Re: NOT NULL columns count [message #317344 is a reply to message #317342] Wed, 30 April 2008 14:15 Go to previous messageGo to next message
saiphani723
Messages: 38
Registered: July 2006
Location: Hyderabad
Member
Result is correct. but i think that is not the correct way of doing. For some columns it is ok. If there are more than 50 columns in that case i think it is bit difficult.
Re: NOT NULL columns count [message #317347 is a reply to message #317344] Wed, 30 April 2008 14:59 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
This is the fastest way.
You can find more complex ones but there are not slower and will not let you type less characters.

Regards
Michel
Previous Topic: ORA-30484: missing window specification for this function
Next Topic: Oracle timestamp
Goto Forum:
  


Current Time: Sat Feb 08 16:49:14 CST 2025