Solved

SQL Query

Posted on 2014-02-03
2
318 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
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…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now