Solved

AS/400 Query

Posted on 2004-04-20
5
1,613 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
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 32

Accepted Solution

by:
shalomc earned 125 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

16 Experts available now in Live!

Get 1:1 Help Now