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. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi

Read-Only Read-Only Topic
Go
Search
Notify
Tools
select distinct
 Login/Join
 
Member
posted
Can anyone suggest how to write code in webfocus for select distinct query like this

select distinct
super.SUPVR_COST_ID,
RTRIM(SUPVR_LNAME) CONCAT ', ' CONCAT RTRIM(SUPVR_FNAME) CONCAT ' ' CONCAT RTRIM(SUPVR_MNAME) as FULL_NAME,
super.SUPVR_CODE,
vg2.LINE_SEG_NBR,
vg2.TRACK_SDTK_NBR,
integer(vg2.MILE_POST_BEG)/1000 + (vg2.MILE_POST_BEG - integer(vg2.MILE_POST_BEG)) as BEGMP,
integer(vg2.MILE_POST_END)/1000 + (vg2.MILE_POST_END - integer(vg2.MILE_POST_END)) as ENDMP,
vg2.SRVY_STN_LEN,
vg2.ELEV_BEG,
vg2.ELEV_END,
vg2.GRADE_PERCENT
from
RIS.TRPT_SUPERVISOR super,
RIS.VGRADE2 vg2
where
super.LINE_SEG_NBR = vg2.LINE_SEG_NBR
and super.SUPVR_COST_ID = ':5'
and super.SUPVR_COST_ID = ':6'
and abs(vG2.GRADE_PERCENT) >= :7
and 1=1
order by LINE_SEG_NBR, BEGMP, TRACK_SDTK_NBR
 
Posts: 14 | Registered: January 11, 2006Report This Post
Expert
posted Hide Post
Yes,

Retain your power within the SQL and pull a recordset using it -

ENGINE SQLORA SET SERVER adaptername
SET SQLENGINE = SQLORA
SQL
select distinct 
super.SUPVR_COST_ID, 
RTRIM(SUPVR_LNAME) CONCAT ', ' CONCAT RTRIM(SUPVR_FNAME) CONCAT ' ' CONCAT RTRIM(SUPVR_MNAME) as FULL_NAME, 
super.SUPVR_CODE, 
vg2.LINE_SEG_NBR, 
vg2.TRACK_SDTK_NBR, 
integer(vg2.MILE_POST_BEG)/1000 + (vg2.MILE_POST_BEG - integer(vg2.MILE_POST_BEG)) as BEGMP, 
integer(vg2.MILE_POST_END)/1000 + (vg2.MILE_POST_END - integer(vg2.MILE_POST_END)) as ENDMP, 
vg2.SRVY_STN_LEN, 
vg2.ELEV_BEG, 
vg2.ELEV_END, 
vg2.GRADE_PERCENT 
from 
RIS.TRPT_SUPERVISOR super, 
RIS.VGRADE2 vg2 
where 
super.LINE_SEG_NBR = vg2.LINE_SEG_NBR 
and super.SUPVR_COST_ID = ':5' 
and super.SUPVR_COST_ID = ':6' 
and abs(vG2.GRADE_PERCENT) >= :7 
and 1=1 
order by LINE_SEG_NBR, BEGMP, TRACK_SDTK_NBR;
TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS MYHOLD
END
-RUN


Now report from the HOLD file named MYHOLD -

TABLE FILE MYHOLD
.......

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
<BillBrockington>
posted
You must add the prefix operator DST. before each field in the PRINT statement. This will cause the SQL code to say select distinct.

TABLE FILE TABLENAME
PRINT
DST.FIELD1
DST.FIELD2
DST.FIELD3
DST.FIELD4
DST.CMPL_NM
WHERE STATEMENTS
END
 
Report This Post
Platinum Member
posted Hide Post
Anubha :
Like Tony says, whenever possible, I would recommend that you use the SQL passthru technique to pull your data and then use the power of focus to massage/format/present data as a report.

This way you are working to the strengths of both - SQL (data extraction) and FOCUS(data manipulation). You would get to thoroughly test/tune your SQL first (EXPLAINs, Build indexes, etc) and then let FOCUS do what it does best.
Here is how it could look like -

SQL DB2 (or whatever engine you got)
SELECT
F1
, F2
, SUM(F3)
FROM HLQ.TBLNAME A
WHERE F99 = 'XX'
GROUP BY F1, F2
;
TABLE
ON TABLE HOLD AS H0001
END
-RUN
-*
TABLE FILE H0001
~~~~~~~ (you know the drill) ~~~~~~~
END

Good luck.
Sandeep M.


-------------------------------------------------------------------------------------------------
Blue Cross & Blue Shield of MS
WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL
MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !! Music
 
Posts: 218 | Location: Jackson, MS | Registered: October 31, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders