Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]How to filter records
Go
New
Search
Notify
Tools
Reply
  
[SOLVED]How to filter records
 Login/Join
 
Member
posted
Hi,
How do I filter out an entire record based on a particular value?

For example
  
TABLE FILE CAR
PRINT SEATS
BY CAR
END


I want to eliminate CAR's where SEATS EQ to 2.
So Alpha Romeo has values of 4, 2 and 2.
I don't want to see the entire record of Alpha Romeo, because one of the values is a 2.
The end result should only show, AUDI, BMW, DATSUN, JENSEN, PEUGEOT and TOYOTA.
Thank you.

This message has been edited. Last edited by: nickz,
 
Posts: 6 | Registered: September 13, 2019Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Hello,
Hope this will be useful

SET ASNAMES=ON

SET HOLDLIST=PRINTONLY

TABLE FILE CAR
PRINT 
SEATS
BY CAR
ON TABLE HOLD AS TEST_1 FORMAT ALPHA
END
-RUN


TABLE FILE CAR
PRINT 
SEATS AS 'FIL_COL'
BY CAR AS 'CAR_1'
WHERE SEATS EQ 2
ON TABLE HOLD AS TEST_2 FORMAT ALPHA
END
-RUN

JOIN CAR IN TEST_1 TO CAR_1 IN TEST_2 AS J2

TABLE FILE TEST_1
PRINT
CAR
SEATS
WHERE FIL_COL NE 2
END
-RUN


Thank You.
 
Posts: 92 | Registered: February 02, 2016Reply With QuoteReport This Post
Master
posted Hide Post
This works with a single request:
 
DEFINE FILE CAR
SEATFLAG/I1=IF SEATS EQ 2 THEN 1 ELSE 0;
END
TABLE FILE CAR

PRINT SEATS
SUM.SEATFLAG WITHIN CAR NOPRINT
BY CAR
WHERE TOTAL SEATFLAG EQ 0;
END 


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 485 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Master
posted Hide Post
Or if you just want a list of the cars without showing the seat numbers:
  
DEFINE FILE CAR
SEATFLAG/I1=IF SEATS EQ 2 THEN 1 ELSE 0;
END
TABLE FILE CAR

SUM SEATFLAG WITHIN CAR NOPRINT
BY CAR
WHERE TOTAL SEATFLAG EQ 0;
END


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 485 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
It is true as Hallway indicates it can be done in one table request. However the WHERE TOTAL has the disadvantage of being performed by WebFocus, so all data is first transferred from the database to the Webfocus server. No problem with small datasets, but if you are dealing with large dataset it could be better to do in 2 passes:

TABLE FILE CAR
PRINT DST.CAR
WHERE SEATS EQ 2;
ON TABLE HOLD AS HLDSEATS2 FORMAT ALPHA
END
-RUN

TABLE FILE CAR
PRINT
CAR
SEATS
WHERE NOT CAR IN FILE HLDSEATS2;
END
-RUN


Or even better with subquery to leave everything to database:

TABLE FILE CAR
PRINT DST.CAR
WHERE SEATS EQ 2;
ON TABLE HOLD AS SQLSEATS2 FORMAT SQL_SCRIPT
END
-RUN

TABLE FILE CAR
PRINT
CAR
SEATS
WHERE NOT DB_INFILE(SQLSEATS2, CAR, CAR);
END
-RUN
-EXIT


Martin.


WebFocus 8203M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
 
Posts: 154 | Registered: March 29, 2013Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Or, if you don't need the output right away:
MATCH
 FILE CAR
 PRINT SEATS
 BY CAR
 RUN
 FILE CAR
 BY CAR
 WHERE SEATS EQ 2;
AFTER MATCH HOLD AS WHATEVER
 OLD-NOT-NEW
END


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1649 | Location: Enschede, Netherlands | Registered: August 12, 2010Reply With QuoteReport This Post
Member
posted Hide Post
Thank you everyone.
 
Posts: 6 | Registered: September 13, 2019Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Good One
 
Posts: 92 | Registered: February 02, 2016Reply With QuoteReport This Post
Master
posted Hide Post
quote:
...Or even better with subquery to leave everything to database:...FORMAT SQL_SCRIPT...

+1
 
Posts: 780 | Registered: April 23, 2003Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]How to filter records

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.