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     [CLOSED] Intermediate SQL Question involving Partition/Over
Go
New
Search
Notify
Tools
Reply
  
[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, 2018Reply With QuoteReport 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.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2225 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Intermediate SQL Question involving Partition/Over

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