Hi,
I am having problems with creating subqueries through query panel. I specifically would like to use the query panel b’cos of the flexibility that the users will get for making changes. The SQL is as follows
SELECT
BLD.SALES_CITY,
CMP.COMPANY_CITY,
BLD.CO_CLLI,
SRV.NPA.NXX
FROM
BUILDING BLD,
COMPANY CMP,
SERVICING_WIRE_NPA SRV
WHERE
(BLD.SALES_CITY = CMP.SALES_CITY)
AND SRV.NPA_NXX =
(SELECT MIN(SERVICING_WIRE_NPA.NPA_NXX)
FROM SERVICING_WIRE_NPA
WHERE BLD.CO_CLLI = SUBSTRING(SERVICING_WIRE_NPA.SWC_CLLI,1,8))
;
The above query gives us results as a free hand sql. Our database sybase sql server. I need to get Building sales_city, company sales_city, minimum NPA_NXX in each co_clli.
If any one has any suggestions of how to desighn as well to create this query will be greatful.
Create the first part of the query:
SELECT
BLD.SALES_CITY,
CMP.COMPANY_CITY,
BLD.CO_CLLI,
SRV.NPA.NXX
Then Drag the SRV.NPA_NXX to the conditions window. Select the Equal to operator.
Select the Create a Subquery Any operand.
In the subquery panel create
SELECT MIN(SERVICING_WIRE_NPA.NPA_NXX), with your newly created min object
Drag the BLD.CO_CLLI to the Conditions window. Select the Equal to operator.
Select the object operand.
Select your newly created SUBSTRING(SERVICING_WIRE_NPA.SWC_CLLI,1,8) object.
Should be about the same as your freehand query.
Robert
Schmidt Interactive Software, Inc.
Hi,
I am having problems with creating subqueries through query panel. I
specifically would like to use the query panel b’cos of the flexibility that the users will get for making changes.
The SQL is as follows
SELECT
BLD.SALES_CITY,
CMP.COMPANY_CITY,
BLD.CO_CLLI,
SRV.NPA.NXX
FROM
BUILDING BLD,
COMPANY CMP,
SERVICING_WIRE_NPA SRV
WHERE
(BLD.SALES_CITY = CMP.SALES_CITY)
AND SRV.NPA_NXX =
(SELECT MIN(SERVICING_WIRE_NPA.NPA_NXX)
FROM SERVICING_WIRE_NPA
WHERE BLD.CO_CLLI =
SUBSTRING(SERVICING_WIRE_NPA.SWC_CLLI,1,8))
It looks like what you need is a “correlated sub-query” using the “Calculation wizard.”
For example, if in your report you want to show the minimum SERVICING_WIRE_NPA.NPA_NXX for each BLD.CO_CLLI, then in your report…
Select your query Result Objects:
BLD.SALES_CITY,
CMP.COMPANY_CITY,
BLD.CO_CLLI,
SRV.NPA.NXX
Choose the object on which you want to apply the condition (NPA_NXX) and place it in the Conditions panel, select your operator (Equal to), and your Operand (Calculation). THE WIZARD BEGINS…
SELECT AN OBJECT: Select the calculation object which will be compared with the condition object. Most of the time these are the same objects (NPA_NXX). {Note: I left out the table qualifier on the NPA_NXX object because as long as you use the same defined object, BusinessObjects will take care of setting up the required aliases.}
SELECT A FUNCTION: Select the calculation to be performed (Min).
SELECT LEVEL OF CALCULATION: Select Globally if no group by is required in the nested query.
SYNCHRONIZE YOUR CALCULATION: Tie the nested query to the outer query by choosing the link object. (BLD.CO_CLLI). This is the “correlation” piece of a correlated sub-query.
SET THE NUMBER OF VALUES TO COMPARE: If you will only be comparing one value (which is true most of the time), choose either option here.
Hi,
I am having problems with creating subqueries through query panel. I specifically would like to use the query panel b’cos of the flexibility that the users will get for making changes. The SQL is as follows
SELECT
BLD.SALES_CITY,
CMP.COMPANY_CITY,
BLD.CO_CLLI,
SRV.NPA.NXX
FROM
BUILDING BLD,
COMPANY CMP,
SERVICING_WIRE_NPA SRV
WHERE
(BLD.SALES_CITY = CMP.SALES_CITY)
AND SRV.NPA_NXX =
(SELECT MIN(SERVICING_WIRE_NPA.NPA_NXX)
FROM SERVICING_WIRE_NPA
WHERE BLD.CO_CLLI =
SUBSTRING(SERVICING_WIRE_NPA.SWC_CLLI,1,8))
;
The above query gives us results as a free hand sql. Our database sybase sql server. I need to get Building sales_city, company sales_city, minimum NPA_NXX in each co_clli.
I am just wondering whether Radhika has solved her problem with corelated subquery. I am facing a similar problem while creating a report. I could create a report using free-hand sql. I am just wondering how can I refer an object from the main query in a conditoin using sub-query. My free-hand SQL is as follows:
SELECT
session_id,
rep_name
FROM
session_log sl,
report_log rl
WHERE
sl.session_id = rl.session_id
AND rl.event_type = ‘A’
AND NOT EXISTS
(
SELECT session_id
FROM report_log a
WHERE event_type = ‘B’
AND a.session_id = rl.session_id
AND a.rep_name = rl.rep_name
)
If you have access to the tech support website, you can check out my presentation from last year’s User Conference. It’s called Using Subquery and Combined Query Techniques and there is a whole section in it on the calculation wizard and correlated queries. Not sure what version of Business Objects you are using, but there is an example on page 100 in the V5 User Guide. In V6, I think it is in the Data Analysis guide probably under Complex Conditions or complex calculations. The V6 explanation is more descriptive and shows you step-by-step what each dialog box means and what options to select.
Again, if you have access to the tech support website, you can open the V6 documentation is PDF format and see what it says, even if you haven’t installed v6 yet. As far as I can tell, the calculation wizard in full client hasn’t changed at all from v5.
If you can’t get at the conference presentation, send me some email and I’ll forward it to you.
I’m using BO to report against PeopleSoft. As you know, PS HRMS is all effective dated. How do I use the complex query calculation wizard to accomplish the same task when using PS’s Query Tool.
For example, I would like to select the latest record in the job table within a particular date range. The proper SQL is as follows:
But when I use the wizard, it returns this:
How would you generate the proper correlated subquery without having to manually edit it? We could always edit the SQL statement and prevent BO from generating its own statement before running but for maintenance practicality it would be nice if we can find a mechnanism to accomplish the historical data look up.
would it be possible to get a copy of this presentation either via e-mail or url? I don’t have access to the BO support site? My email is chris_chesebro@bose.com