Solved

SyBase SQL Querry Syntax

Posted on 2014-03-07
1
274 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
[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
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

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 …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

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