Solved

SQL syntax

Posted on 2011-09-28
6
234 Views
Last Modified: 2012-05-12
I am getting a compile error as follows:

Incorrect syntax near the keyword 'AND'.

How do I rewrite this script -- so that both parameters are checked for '0' in order to be counted.
, COUNT(case NetworkCause WHEN 0 AND case PrepaidCause WHEN 0 THEN NetworkCause END)

Open in new window

0
Comment
Question by:amillyard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 36717182
COUNT(CASE WHEN NetworkCause = 0 AND PrepaidCause = 0 THEN NetworkCause END)
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36717189
Note that that is the same thing, in this instance, as:

COUNT(CASE WHEN NetworkCause = 0 AND PrepaidCause = 0 THEN 0 END)
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 36717191
COUNT(CASE WHEN NetworkCause + PrepaidCause = 0 THEN NetworkCause END)
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 33

Expert Comment

by:knightEknight
ID: 36717199
hmm, my suggestion assumes that both columns contain only positive values or 0 -- if this is not the case then scratch it.  :)
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 36717202
but points to matthewpatrick pls
0
 

Author Closing Comment

by:amillyard
ID: 36717289
matthewspatrick:  many thanks - works great :-)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question