?
Solved

AS/400 Query

Posted on 2004-04-20
5
Medium Priority
?
1,641 Views
Last Modified: 2008-02-01
Is it possible to do any type of "If/Then" statement in Query.  I need to filter out some negative number results without filtering out the whole record with a statement saying that if the field is less than zero, move zero to a new field and then have that new field displayed on the report.

Thanks you.
0
Comment
Question by:pseils
[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
5 Comments
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 10873230
No not directly in 1 step, what you can do is create an Query that select all your records with "good" data and send them to a temp file.
in step 2 you take the dame query and filter the "Bad"records and append them to the same file (without the unwanted field(s)). In the temp file these fields will remain blank or zero.
Now you can generate the report.


0
 
LVL 33

Accepted Solution

by:
shalomc earned 500 total points
ID: 10875457
If you use Query Management Queries rather than Query400, then it is possible.

In QMQRY, you can embed SQL in the query object, and use SQL case, like this:

table description
-------------------
item char 15
onhand dec 15,5

select item, case when onhand<0 then 0 else onhand end as onhand from inv_file


ShalomC
0
 
LVL 27

Expert Comment

by:tliotta
ID: 10884165
pseils:

If you mean the Query/400 product, the easiest way is to create an SQL VIEW that presents the data in the way you need it, then write your query over that view.

But this really isn't a task for Query/400. As mentioned by ShalomC, a Query Management query is better suited. One potential issue is that you don't have the SQL Development Kit product. That would make it harder.

Fortunately, you could still create and use QM queries; you'd just need to learn the details of do-it-yourself.

Tom
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 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