Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering using a temporary field 1

Status
Not open for further replies.

PeterG5

Programmer
Apr 29, 2003
68
IE
Hi All,

It's all a bit new to me and I know how to do this in other
languages, so can anyone please help me?

I want to define a temporary field and then use it as a
filtering condition, like this.....

SELECT (SNAP.SO_VIEW_ID ||
SNAP.SO_STATUS_LAST_ID ||
SNAP.SO_STATUS_NEXT_ID) AS MOJO_FILTER,
etc, etc,.....

WHERE (MOJO_FILTER NOT IN ('S620999', S900999')).....

DB/2 SQL does not seem to like this.....

Many Thanks,

Peter.

[thumbsup]
 
You can't define a temp field in the select and use it in the Where clause. What I would do is use a temporary table expression:

With mojo_filter(ID)
As (
Select SNAP.SO_VIEW_ID ||
SNAP.SO_STATUS_LAST_ID ||
SNAP.SO_STATUS_NEXT_ID
From snap )

Select so_and_so
from mojo_filter
where id not in ('S620999', S900999')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top