Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 97
  • Last Modified:

sql query

how to write a pl sql which will count the number of not null rows in a column and update another table with the sum?
0
sam shah
Asked:
sam shah
1 Solution
 
PortletPaulCommented:
PL/SQL is Oracle, so I  added that topic.
Is ms sql server not relevant?

Could you elaborate on your question with a small example. Include the real tables names and column name you want updated.
0
 
HuaMinChenBusiness AnalystCommented:
Try
Update Tab1
set col1=(select count(1) from Tab2 where nvl(col2,'')<>'');

Open in new window

0
 
ste5anSenior DeveloperCommented:
There is no such think like a null row. What is your concrete problem?
0
 
slightwv (䄆 Netminder) Commented:
HuaMinChen,

That won't work.  Oracle treats an empty string as a null.



sam,

To update a COLUMN with the count of not null COLUMNS:
update some_table set some_column=(select count(*) from another_table where some_column is not null);

I suspect the real answer is a little more complex than that.  As Paul and ste5an suggested, can you explain more about the actual requirements?
0
 
awking00Commented:
Sample data with table names and structures, column names and their data types, plus the expected results is ALWAYS helpful.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now