Go Premium for a chance to win a PS4. Enter to Win

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

SQL syntax

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
amillyard
Asked:
amillyard
  • 3
  • 2
1 Solution
 
Patrick MatthewsCommented:
COUNT(CASE WHEN NetworkCause = 0 AND PrepaidCause = 0 THEN NetworkCause END)
0
 
Patrick MatthewsCommented:
Note that that is the same thing, in this instance, as:

COUNT(CASE WHEN NetworkCause = 0 AND PrepaidCause = 0 THEN 0 END)
0
 
knightEknightCommented:
COUNT(CASE WHEN NetworkCause + PrepaidCause = 0 THEN NetworkCause END)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
knightEknightCommented:
hmm, my suggestion assumes that both columns contain only positive values or 0 -- if this is not the case then scratch it.  :)
0
 
knightEknightCommented:
but points to matthewpatrick pls
0
 
amillyardAuthor Commented:
matthewspatrick:  many thanks - works great :-)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

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