Solved

SQL Query

Posted on 2014-02-03
2
358 Views
Last Modified: 2014-02-03
SyBase SQL Anywhere v10

Hey guys,

I am trying to return a preset text result if a specific condition is met. Example:

select POSHEADER.transact, POSHEADER.snum, POSHEADER.statnum, whoclose, timeend, POSHEADER.finaltotal, POSHEADER.status, METHODPAY.descript……

I don’t want it to actually select the POSHEADER.finaltotal value, but rather return a result of “Sale” if finaltotal is > 0 and a result of “Return” if finaltotal is < or = 0. Also the returned value needs to be in column 6.
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
2 Comments
 
LVL 26

Accepted Solution

by:
wilcoxon earned 500 total points
ID: 39831392
select POSHEADER.transact,
POSHEADER.snum,
POSHEADER.statnum,
whoclose,
timeend,
case when POSHEADER.finaltotal > 0 then 'Sale' else 'Return' end,
POSHEADER.status,
METHODPAY.descript……

Open in new window

0
 

Author Closing Comment

by:triphen
ID: 39831535
Perfect....I had the same thing but my entire query was on one line.....it was working before I added the CASE statement. Thanks again!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

734 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