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] WebFOCUS Equivalent to SQL DENSE_RANK

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] WebFOCUS Equivalent to SQL DENSE_RANK
 Login/Join
 
Expert
posted
Hello FocalPointers,

I'm looking to convert the SQL "DENSE_RANK" command to WebFOCUS code? Is there a direct way to do this? Or, should it be done via a HOLD file or two? I'm not looking to have someone do this for me, just some Pointers would be fine.

Has anyone successfully done this in WebFOCUS?

More info on the SQL "DENSE_RANK" command can be found right here, and here.

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




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
Hi Doug, doubt this simple code is what you are looking for, but, here goes anyway:

  
TABLE FILE CAR
SUM
    DEALER_COST/P13.2M AS 'Dealer Cost'
    RETAIL_COST/P13.2M AS 'Retail Cost'
      COMPUTE PROFIT/P13.2M = RETAIL_COST-DEALER_COST; AS 'Profit'
    SALES/P13.2M AS 'Sales'
   BY COUNTRY AS 'Country'
   RANKED AS 'Rank'
   BY DEALER_COST NOPRINT
   BY CAR AS 'Car'
   BY MODEL AS 'Model'
   BY BODYTYPE AS 'Body Style'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON
ON TABLE PCHOLD FORMAT HTML 
ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.400000,
     RIGHTMARGIN=0.050000,
     TOPMARGIN=0.000000,
     BOTTOMMARGIN=0.000000,
     ORIENTATION=LANDSCAPE,
     SQUEEZE=ON,
$
TYPE=TITLE, STYLE=BOLD, SIZE=10, FONT=VERDANA,$
TYPE=REPORT, TITLETEXT='Report 1',$
ENDSTYLE
END
-RUN
-EXIT


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
BTW, you could also set a counter in conjuction with using WITHIN, another option...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
Thats, that's pretty close Tom.

I forgot to add that I need the MIN and MAX of, in your case, DEALER_COST within COUNTRY. We can remove the RETAIL_COST and SALES (for simplicity).

Similar to this SQL code:
SELECT empno,
       deptno,
       sal,
       MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
       MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
FROM   emp
ORDER BY deptno, sal;

     EMPNO     DEPTNO        SAL     Lowest    Highest
---------- ---------- ---------- ---------- ----------
      7934         10       1300       1300       5000
      7782         10       2450       1300       5000
      7839         10       5000       1300       5000
      7369         20        800        800       3000
      7876         20       1100        800       3000
      7566         20       2975        800       3000
      7788         20       3000        800       3000
      7902         20       3000        800       3000
      7900         30        950        950       2850
      7654         30       1250        950       2850
      7521         30       1250        950       2850
      7844         30       1500        950       2850
      7499         30       1600        950       2850
      7698         30       2850        950       2850
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
Well, I don't see anything ranked there, just low-to-high salaries? What am I missing???

  
TABLE FILE CAR
SUM
  MIN.DEALER_COST AS 'Lowest'
  MAX.DEALER_COST AS 'Highest'
BY COUNTRY AS 'Country'
SUM
     DEALER_COST
BY COUNTRY AS 'Country'
RANKED AS 'Rank'
BY DEALER_COST NOPRINT
BY CAR AS 'Car'
BY MODEL AS 'Model'
BY BODYTYPE AS 'Body Style'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON
-* ON TABLE PCHOLD FORMAT EXL2K OPEN
ON TABLE PCHOLD FORMAT &FMT  
ON TABLE SET STYLE *
     UNITS=IN,
     PAGESIZE='Letter',
     LEFTMARGIN=0.400000,
     RIGHTMARGIN=0.050000,
     TOPMARGIN=0.000000,
     BOTTOMMARGIN=0.000000,
     ORIENTATION=LANDSCAPE,
     SQUEEZE=ON,
$
TYPE=TITLE, STYLE=BOLD, SIZE=10, FONT=VERDANA,$
TYPE=REPORT, TITLETEXT='Report 1',$
TYPE=REPORT, COLUMN=N2, SEQUENCE=98, COLOR=BLUE,$
TYPE=REPORT, COLUMN=N3, SEQUENCE=99, COLOR=RED,$

ENDSTYLE
END
-RUN
-EXIT

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
Yea Tom,

That does it... I was over complicating things neglected the multi-verb stuff.

Kudos To You Big Grin
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
SET BYDISPLAY=ON
DEFINE FILE CAR
LASTDC/D20C = LAST DCOST
END
TABLE FILE CAR
SUM MIN.DEALER_COST AS 'Lowest'
    MAX.DEALER_COST AS 'Highest'
    LASTDC NOPRINT
RANKED BY DEALER_COST AS 'Dealer Cost'
BY COUNTRY AS 'Country'
BY CAR AS 'Car'
BY MODEL AS 'Model'
BY BODYTYPE AS 'Body Style'
ON TABLE SET PAGE-NUM OFF
ON TABLE SET HTMLCSS ON
ON TABLE PCHOLD FORMAT &FMT
ON TABLE SET STYLE *
UNITS=IN,PAGESIZE='Letter', ORIENTATION=LANDSCAPE, SQUEEZE=ON,$
TYPE=REPORT, TITLETEXT='DENSE_RANK sample',$
TYPE=TITLE, STYLE=BOLD, SIZE=10, FONT=VERDANA,$
TYPE=REPORT, COLUMN=N3, SEQUENCE=2,$
TYPE=REPORT, COLUMN=N4, SEQUENCE=3,$
TYPE=REPORT, COLUMN=N2, SEQUENCE=6,$
TYPE=DATA, BACKCOLOR=RGB(222 222 222), COLOR=RED, WHEN = DEALER_COST EQ LASTDC,$
ENDSTYLE
END
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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] WebFOCUS Equivalent to SQL DENSE_RANK

Copyright © 1996-2020 Information Builders