sql server 2008 - How to count for records with empty values in 3 colums -


I'm not a SQL Server 2008 expert, but that's what I'm trying to do. Let's say I have this table:

I have to calculate those records which do not have values ​​in col2, col3 , and col4 , Code> col1 = 1 , I've tried to do this:

  from the SELECT COUNT (col1) table where len (col2) & gt; 1 or LAN (col 3) & gt; 1 or lennon (col4)> 1 and col1 = '1'   

But I get thousands of records. If any of you can help me or point me in the right direction, then I appreciate it.

Thank you.

  SELECT COUNT (col1) = "text"> 

operator preference Check it at 'and' before it is evaluated 'or' your example looks like:

  where to take from the SELECT COUNT (col1) table (col2) & gt; 1 or LAN (col 3) & gt;   

Such records should be counted that you do not have the value

But if your code is counting the records that do the values, then you might want it: < WHERE col1 = '1' and (col2 is NULL or col3 is NULL or col4 is NULL) from pre> SELECT COUNT (col1) table.

You can show data in which Value is when you say:

Where lane (col2) & gt; 0

But if the call is 2 cord, then the lane (col2) is the same tap zero is not zero.

If your string is '' instead of zero, then you can check LENgth:

  SELECT COUNT (col1) WHERE col1 = '1' from the table and (Lan (col2) = 0 or len (col3) = 0 or lenan (col4) = 0) And of course, if you really want to see those values Those who were not empty:  
  WHERE col1 = '1' and (langan (col2)> gt or 0 or lan (s) by SELECT COUNT (col1) table Col4)> 0)   

In addition to your example, you said that LEN () was & gt; 1. Do you mean more than 1 or zero?

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -