Solved

SyBase SQL Querry Syntax

Posted on 2014-03-07
1
265 Views
Last Modified: 2014-03-07
I am trying to return a sum only if it's > 0 else, I want to return 0.

This is what I have now.

Select sum(quan*costeach) from dba.posdetail where prodnum in (select prodnum
from dba.product where reportno = 993301) and transact = 100

Open in new window


If the sum is > 0 then return the sum, else return 0.
0
Comment
Question by:triphen
1 Comment
 

Accepted Solution

by:
triphen earned 0 total points
ID: 39914194
Never mind I got it :)

Select case when sum(quan*costeach)  > 0 then sum(quan*costeach) else '0' end from dba.posdetail where prodnum in (select prodnum from dba.product where reportno = 993301) and transact = 2001
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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