Focal Point
[CLOSED] Subquery/WHERE IN FILE???

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/819106983

March 08, 2010, 06:24 PM
neuro
[CLOSED] Subquery/WHERE IN FILE???
I am trying to convert a MS SQL report into WebFocus and I end up creating a temp table called #Affinity and then I query from it. I have a SQL that does sub queries in the select statement as shown below. How would I go about doing this when I have a TABLE FILE called "AFFINITY" and I need to basically sub query it like below?


DISPLAYTEXTHEADLINE1 =
(SELECT DISTINCT(A1.DISPLAYTEXTHEADLINE) FROM #Affinity A1 WHERE A1.ORDERID = A0.ORDERID AND A1.LINENUM = A0.LINENUM AND A1.DISPLAYTEXTHEADLINE is not null AND A0.DISPLAYTEXTLOGO is not null),
DISPLAYTEXTLOGO1 =
(SELECT TOP 1 A2.DISPLAYTEXTLOGO FROM #Affinity A2 WHERE A2.ORDERID = A0.ORDERID AND A2.LINENUM = A0.LINENUM AND A2.DISPLAYTEXTLOGO is not null AND A0.DISPLAYTEXTLOGO is not null),
DISPLAYTEXTACCOUNT1 =
(SELECT DISTINCT(A3.DISPLAYTEXTACCOUNT) FROM #Affinity A3 WHERE A3.ORDERID = A0.ORDERID AND A3.LINENUM = A0.LINENUM AND A3.DISPLAYTEXTACCOUNT is not null AND A0.DISPLAYTEXTACCOUNT is not null),


Searched forum and reading manuals and cannot figure it out.

Thanks if anyone can guide me in right direction.

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


Currenly working @ Learning Circle Education Services
Previously worked @ Nationwide Insurance
Prod: WebFOCUS 7.6.11


Test: WebFOCUS 7.6.11


Dev: WebFOCUS 7.6.11
March 08, 2010, 06:34 PM
Waz
Although I'm not an expert in SQL, but it looks like you are setting the value for the fields from each sub query.

If so, you may?? be able to use the DB_LOOKUP function.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

March 08, 2010, 07:44 PM
Dan Satchell
You might try something like this:

TABLEF FILE AFFINITY
 SUM MAX.DISPLAYTEXTLOGO
 BY DISPLAYTEXTHEADLINE
 BY DISPLAYTEXTACCOUNT
 WHERE DISPLAYTEXTHEADLINE IS-NOT MISSING ;
 WHERE DISPLAYTEXTACCOUNT IS-NOT MISSING ;
END



WebFOCUS 7.7.05
March 09, 2010, 12:24 AM
Ram Prasad E
Dan, there is a chance to end up with NULL for DISPLAYTEXTLOGO. It should be like

TABLE FILE AFFINITY
SUM 
  MAX.DISPLAYTEXTLOGO
  MAX.DISPLAYTEXTHEADLINE
  MAX.DISPLAYTEXTACCOUNT
END



WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
March 09, 2010, 07:49 AM
Dan Satchell
Ram,

You are correct. It was meant to be a multi-verb request, but I failed to include one important line:

TABLEF FILE AFFINITY
 SUM MAX.DISPLAYTEXTLOGO
 SUM DISPLAYTEXTHEADLINE NOPRINT
 BY DISPLAYTEXTHEADLINE
 BY DISPLAYTEXTACCOUNT
 WHERE DISPLAYTEXTHEADLINE IS-NOT MISSING ;
 WHERE DISPLAYTEXTACCOUNT IS-NOT MISSING ;
END



WebFOCUS 7.7.05