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

x
?
Solved

SQL Select statement question

Posted on 2008-11-05
4
Medium Priority
?
185 Views
Last Modified: 2012-05-05
Hello, how can I subtract 23 from sum(tblCountData.Incount) only if the value is greater than 0?

SELECT tblCountData.RecDate, sum(tblCountData.Incount) AS trafficcount
FROM tblCountData
GROUP BY tblCountData.RecDate;
0
Comment
Question by:Sean Rhudy
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Binuth earned 500 total points
ID: 22892230
SELECT
tblCountData.RecDate,
case when sum(tblCountData.Incount) > 0 then sum(tblCountData.Incount)- 23 Else sum(tblCountData.Incount) END AS trafficcount
FROM tblCountData
GROUP BY tblCountData.RecDate;
0
 

Author Comment

by:Sean Rhudy
ID: 22892246
It says: syntax error (missing operator) in query expression
0
 

Author Comment

by:Sean Rhudy
ID: 22892248
I'm using Access 2007
0
 
LVL 14

Expert Comment

by:Binuth
ID: 22892252
the query that posted for MS sql server, Sorry i can't help you in Access 2007
0

Featured Post

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.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

581 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