Solved

SQL Query

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Currency in SQL? 2 45
RAISERROR WITH NOWAIT 2 25
Pivot tables in SQL 1 37
Need quicker response from an Execption table 11 24
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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