Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] SQL Sub Select using FOCUS

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] SQL Sub Select using FOCUS
 Login/Join
 
Silver Member
posted
Hi All,

I have been wracking my brain trying to figure out a way to do this. I'm not sure if it can even be done. I am told it can be done using a SQL Sub Select, but I do not know SQL at all and am wondering if it is possible with FOCUS.

Here is my data:

Orig Ord Ord Nbr Entry Date Ship Date
123 123 20090303 20090303
123 123 20090303 20090303
123 123 20090303 20090303
123 456 20090303 20090304
123 456 20090303 20090304
123 456 20090303 20090304


I need to filter this by a particular Ship Date, but I also need all the records for the Orig Ord. The Entry Date is always the same for both orders. The Ship Dates can be different by Ord Nbr and the Orig Ord could have a later Ship Date than the second order.

Hopefully this is enough info.

Thank you so much for any help - even if it is to tell me if it can be done or not, so I can quit wracking my brain if it can't!

Krysti

This message has been edited. Last edited by: Kerry,


WF 767
 
Posts: 34 | Location: Chicago, IL | Registered: September 02, 2004Report This Post
Gold member
posted Hide Post
I don't know if you are looking for this....

Here is the sample query.

select * from TableA
where origin_ord in
(select distinct origin_ord from TableA where ship_Date = '20090304')

If above SQL doesn't solve your requirement, I guess it would be better if you tell the actual result set.

WF 7.1.7


Prod: WF 7.6.10 windows. -- MRE/Dashboard/Self Service/ReportCaster - Windows XP
 
Posts: 82 | Location: Chicago | Registered: September 28, 2005Report This Post
Expert
posted Hide Post
Just using WebFOCUS without SQL, you could perform a pre extract to hold all the order numbers that have an order with a ship date equal to that required.

Then either use that in an IF field EQ (filename), or if the file is greater than 32000 bytes (the limit for EQ (filename) use it within a join, or you could use match logic like this -

Bear in mind that the first part is only to build some sample data to show you the technique

EX -LINES 6 EDAPUT MASTER,KrystiOrd,CF,MEM,FILENAME=KrystiOrd, SUFFIX=FOC,$
SEGNAME=ONE, SEGTYPE=S0 ,$
  FIELD=Orig_Ord,     ,A5    ,A5    ,$
  FIELD=Ord_Numb,     ,A9    ,A9    ,$
  FIELD=Entry_Date,   ,YYMD  ,YYMD  ,$
  FIELD=Ship_Date,    ,YYMD  ,YYMD  ,$
-RUN
CREATE FILE KrystiOrd
MODIFY FILE KrystiOrd
FREEFORM Orig_Ord Ord_Numb Entry_Date Ship_Date
DATA
123,1231,20090303,20090303,$
123,1232,20090303,20090304,$
123,1233,20090303,20090305,$
234,2341,20090303,20090303,$
234,2342,20090303,20090304,$
234,2343,20090303,20090305,$
345,3451,20090303,20090306,$
345,3452,20090303,20090307,$
345,3453,20090303,20090308,$
END
-RUN
MATCH FILE KrystiOrd
BY Orig_Ord
WHERE Ship_Date EQ '2009/03/04'
RUN
FILE KrystiOrd
PRINT Ship_Date
   BY Orig_Ord
   BY Ord_Numb
   BY Entry_Date
AFTER MATCH HOLD OLD
END
-RUN
TABLE FILE HOLD
PRINT *
END

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
Using focus code, I would do it as follows:
TABLE your data, filtered on the specified ship_date, and hold the data, specifically the OrigOrd field. See to it that you have only one record per origord value (ie use SUM). Next join this hold file to the source table using the origord field as join field. This will give you all records that have at least one record with the requested ship_date.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
T, you just beat me to it. But we think along the same lines....


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
This also does the trick, with one pass on the data:
 
DEFINE FILE KrystiOrd
TD/I1=IF Ship_Date EQ '2009/03/04' THEN 1 ELSE 0;;
END
TABLE FILE KrystiOrd
PRINT Ship_Date 
COMPUTE TT/I1=IF Orig_Ord NE LAST Orig_Ord THEN TD ELSE LAST TT; NOPRINT
BY Orig_Ord 
BY HIGHEST TD NOPRINT
BY Ord_Numb 
BY Entry_Date 
WHERE TOTAL TT EQ 1
END


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Silver Member
posted Hide Post
Thank you all for your help.

I ended up joining back to the source table. I originally didn't want to do that because I thought it would not be efficient, however, there didn't end up being a problem.

Danny - thanks for showing me how to do it in one pass. That's what was driving me crazy. Unfortunately, using a define took way too long and the source data is not in the correct order to use the LAST function (if I understand correctly, the sort doesn't happen until after the compute). Please correct me if I'm wrong on that...

Thanks for the SQL sample also. I didn't use it because joining back to the source worked out and without knowing SQL, it was going to take me too long to figure out how to write it with the rest of the scenario of the data.

Thank you again for all your help. This forum is a great resource, especially when you're really under the gun. I really appreciate all you guys so much!

Krysti


WF 767
 
Posts: 34 | Location: Chicago, IL | Registered: September 02, 2004Report This Post
Virtuoso
posted Hide Post
Krysti,

quote:
Unfortunately, using a define took way too long and the source data is not in the correct order to use the LAST function (if I understand correctly, the sort doesn't happen until after the compute). Please correct me if I'm wrong on that...


1. Interesting what you say about the DEFINE. Did you do a MATCH? Did you do a HOLD and join to the original table? Did you create an SQL table and join to the original?

2. No, COMPUTE is done after the sort, hence the LAST function works like a charm. DEFINEing TD and sorting by it, will put all your wanted ship dates up front, then the COMPUTE "colors" all the Orig_Ord and they are screened after sort and COMPUTE by the WHERE TOTAL condition.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Silver Member
posted Hide Post
Danny,

Sorry it took me so long to reply back to you.

1. I ended up querying for the ship date, holding that and then joining back to the source table.

2. Thanks for correcting me on the compute. I must have gotten that confused with something else I heard about the order in which things happen.

The reason the Define took too long in my situation is because our response time here is not great.

Thanks again,

Krysti


WF 767
 
Posts: 34 | Location: Chicago, IL | Registered: September 02, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] SQL Sub Select using FOCUS

Copyright © 1996-2020 Information Builders