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     [CLOSED] Intermediate SQL Question involving Partition/Over

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Intermediate SQL Question involving Partition/Over
 Login/Join
 
Member
posted
I have two tables. The first looks like this:

Unit Status
1001 A
1002 A
1003 A
1004 A
1005 A
1006 A
1007 A
1008 A
1009 A
1010 A

The second looks like this:

Unit Status
2001 Z
2002 T
2003 X
2004 W
2005 M

I would like to join these two tables in such a way that every unit in the 2 table is "assigned" 2 units from the 1 table. For example, Unit 2001 is "assigned" units 1001 and 1002, unit 2002 is "assigned" units 1003 and 1004, and so on. The order is not important, just that two unique units from table 1 are assigned to one unit from table two.

I would like my final product to look something like this:

Unit Status Assignment_1 Assignment_2
2001 Z 1001 1002
2002 T 1003 1004

And so forth.

Any help would be greatly appreciated! Of course if you want to tell me to go take more SQL training, that is fine too!

Thanks!

This message has been edited. Last edited by: FP Mod Chuck,


intsoccersuperstar
WebFOCUS 8105m
Windows, Excel
 
Posts: 16 | Registered: October 17, 2018Report This Post
Virtuoso
posted Hide Post
Not sure to understand the purpose of this, but with a few coding I can have the below
TABLE FILE CAR
SUM COMPUTE IDXT  /I2 = IDXT + 1; NOPRINT
    COMPUTE IDX   /I2 = IF DMOD(IDXT, 2, 'I2') EQ 0 THEN LAST IDXT ELSE IDXT;
    COMPUTE ROWID /I2 = IF LAST ROWID EQ 1 THEN 2 ELSE 1;
BY CAR
ON TABLE HOLD AS SRCA
END
-RUN

TABLE FILE CAR
SUM COMPUTE IDX/I2 = IF IDX EQ 0 THEN 1 ELSE IDX + 2;
BY COUNTRY
ON TABLE HOLD AS SRCB FORMAT FOCUS INDEX IDX
END
-RUN

JOIN 
     IDX IN SRCA
  TO IDX IN SRCB TAG J1 AS J1
END
SET ACRSVRBTITL  = ON
TABLE FILE SRCA
SUM CAR    AS 'Car'
BY COUNTRY AS 'Country'
ACROSS ROWID NOPRINT
ON TABLE SET PAGE-NUM NOLEAD
END
-RUN

Please, when posting sample data, format or code, use the tag code (last one on the ribbon) :
</>


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report 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     [CLOSED] Intermediate SQL Question involving Partition/Over

Copyright © 1996-2020 Information Builders