Multiple or Single Query?
I am trying building a ConstituencyMap of electoral
Constituencies each of which a couple of polling stations. I want
to output information containing the Name and Region of each
constituency and also a running total of the votes from each
polling station in that constituency until all polling stations in
that constituency have reported their results. Further more I will
use a query to find out which party won and change the color of the
cell to the parties assigned color.
My question is how do I get all this information in a single
cell. I do not know if I can use multiple query values in the same
logic. For example, my code to show the constituency name and
region is as attached. Being a novice in databases, I would rather
use multiple queries and try to add the results to the cell, but I
do not know if this is possible, I think a single query drawing
information from my multiple table would be the way to go, but this
would be a complex query.
I will appreciate any insight into this. Thanks
As well as Dan's suggestion for "Teach Yourself SQL in 10
Minutes" by
Ben Forta.
You can reference multiple queries. You just have to
reference the
record set data structure yourself, rather then relying on a
shortcut
such as <cfoutput query="aQuery">
A fully qualified record set reference is
queryName.columnName[row] OR
queryName['columnName'][row].
I.E.
<cfquery name="aQry".../>
<cfquery name="bQry".../>
<cfoutput>
#aQry.aColumn[1]# <---> #bQry['bColumn][2]
</cfoutput>
Similar Messages
-
How to use multiple hierarchies for a single char in single query
Hi,
Is there any way that we can use multiple hierarchies for a single char in single query. I tried and it just allows me to select one hierarchy even if I use hierarchy variable.
I have a requirement where user wants to see information related to a cost center with different cost center groups in different hierarchies (every year has different cost center group hierarchies).
Suppose I want to see information related to a cost center from year 2001-2004.in these four year cost center may have been associated to different groups depending upon that year hierarchy. How can I do that?
Thanks
JonaNope. Now way to do this.
There is always just one hierarchy assigned to a characteristic. And even if the hierarchy was time dependent, it only reads it for one key date and not according to transaction data.
Regards,
Beat -
Multiple databases in a single query
I need to query multiple databases in a single query.
e.g.
Database d1 contains table t1 with column id
Database d2 contains table t2 with column id
I need a query like
SELECT * FROM t1, t2 WHERE t1.id = t2.id;
is this possible in jdbc? if yes can anyone help with some sample code?
thanks,
Ashish SarafIt is not possible using the JDBC API to query tables in two or more databases using a single query. The reason is that a JDBC Connection is made to a single data source.
However, some databases support the idea of federations or linked tables. What you do is inside the database manager link or federate a table that is present in another DBMS. Then, pose a single JDBC query to the one DBMS which will have its own table and links to the external tables.
Another approach is to use a special JDBC driver with a built-in integration engine that will perform a query across multiple databases. In effect, the system poses separate queries to the different databases and integrates and joins the data together for you automatically on the client-side. That is much easier than doing it yourself in code, but that is also possible for simple queries.
As part of my research program, we have released a shareware version of the UnityJDBC driver that can query multiple databases using a single SQL query. For more information, see:
http://www.unityjdbc.com
http://www.cs.uiowa.edu/~rlawrenc/research/projects.html
Sincerely,
Dr. Ramon Lawrence
Assistant Professor
Department of Computer Science
University of Iowa
[email protected] -
Populate Multiple Items bundled in a single query
Hello,
I am trying to create a report in which I have mulitple items that I want to populate. All of these use the same query but use different rows in the query to populate themselves. My question is:-
Is there a way to bundle the item assignment into a single query and populate the items from there? I want to reduce the time it takes for me to display the report and just hit the database once instead.Hi there,
when u say report, i think its a more of a page showing few items on a region whose values are populated from Database rather than a SQL report which will not have any items. Is that correct?
yes, multiple items of a page can be assigned values at once.
assume: P1_ITEM1,P1_ITEM2,P1_ITEM3,P1_ITEM4 are different items on a page, an "On-Load Before Header" PL/SQL process can be created to assign values to the items in this way:
SELECT tab.col1,tab.col2,tab.col3,tab.col4 INTO :P1_ITEM1,:P1_ITEM2,:P1_ITEM3,:P1_ITEM4 FROM TABLE tab;
Item "Source Used" should be of type: Only When Current Value in session state is null
Source Type: PL/SQL Expression or function
and Source Value or EXpression should be some thing like this :P1_ITEM1
Hope this helps.
Edited by: Chaitu_Apex on Mar 10, 2010 2:43 PM -
How to calculate the individual sums of multiple columns in a single query
Hello,
Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
Will appreciate any help or suggestion.
Thanksuser13667036 wrote:
Hello,
Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
Will appreciate any help or suggestion.
ThanksLooks like you want a simple group by.
select
yr
, mnth
, region
, sum(handled_package)
, sum(expected_missing_package)
, sum(actual_missing_package)
from test
group by
yr, mnth, region
order by
yr, mnth, region;I wouldn't recommend storing your data for year / month in 2 columns like that unless you have a really good reason. I would store it as a date column and add a check constraint to ensure that the date is always the first of the month, then format it out as you wish to the client.
CREATE TABLE test
year_month date,
Region VARCHAR2(50),
CITY VARCHAR2(50),
Handled_Package NUMBER,
Expected_Missing_Package NUMBER,
Actual_Missing_Package NUMBER
alter table test add constraint firs_of_month check (year_month = trunc(year_month, 'mm'));
ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
2 Values (to_date('2012-nov-12', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
ERROR at line 1:
ORA-02290: check constraint (TUBBY.FIRS_OF_MONTH) violated
Elapsed: 00:00:00.03
ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
2 Values (to_date('2012-nov-01', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
1 row created.
Elapsed: 00:00:00.01
ME_XE?select
2 to_char(year_month, 'fmYYYY') as year
3 , to_char(year_month, 'fmMonth') as month
4 , Region
5 , CITY
6 , Handled_Package
7 , Expected_Missing_Package
8 , Actual_Missing_Package
9 from test;
YEAR MONTH REGION CITY HANDLED_PACKAGE EXPECTED_MISSING_PACKAGE ACTUAL_MISSING_PACKAGE
2012 November Western San Fransisco 200 10 5
1 row selected.
Elapsed: 00:00:00.01
ME_XE?Then you have nice a nice and easy validation that ensures you data integrity.
Cheers, -
How to insert multiple records in a single query
Dear all,
Can you please tell
how to insert multiple records in a single query ??INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
INSERT INTO table_name
(column_1, column_2)
SELECT 'value_A', 'value_B' FROM DUAL
UNION ALL
SELECT 'value_C', 'value_D' FROM DUAL
;Edited by: Benton on Nov 9, 2010 1:59 PM -
Single report with multiple queries OR multiple reports with single query
Hello Experts,
I have a confusion regarding Live Office connection for many days. I asked many people but did not get a concrete answer. I am re-posting this question here and expecting an answer this time.
The product versions that I am using are as follows:
FrontEnd:
BOE XI 3.1 SP4 FP 4.1
Xcelsius Enterprise 2008 SP4
Backend:
SAP BW 7.0 EHP1
I have created a dashboard which is getting data from a webi report using LO connections.
The webi report has five report parts which are populated by five different queries.
Now my question is, when the five LO connections are refreshed, is the webi report refreshed five times or just once?
If the report is refreshed five times, then I guess it is better to have five different webi reports containing single report part, because in that way we can prevent same query being executed multiple times.
SO what is the best practice- to have a single report having multiple queries - OR - to create multiple webi reports with single query?
Thanks and Regards,
PASGHI
I think Best Practice is Multiple reports with single query
Any way If LO connections refresh 5 time the query will refresh 5 timesRegards
Venkat -
Query Design Strategies - servicing multiple reports from a single query
I was wondering if anyone knew of any good web resrouces (articles and such) to assist with Query Design Strategies. What I am specifically looking to do is replace multiple reports from the previous system with just views of a single query. So I was looking at grouping the existing reports that we are replacing into queries and creating views for each report.
The catch is that we will only be utilizing web reporting for report distribution, so we need to:
1. Use views as DataProviders to web templates
2. Broadcast views to users as links where they can see that particular view
Is this possible and does anyone have some info on how to do this?Lets say that 10 broadcasted reports all could use the same query but each in a different navigational state.
1. Can you navigate the query and save as a view and then set up a brodacast rule for that view?
2. Can a DataProvider in a web template be a view?
3. Can the BI Launcher iView take a view name in place of a query?
<prt_protcl>://<prt_server>/<bi_launcher>?TEMPLATE=TEST1&QUERY=TEST2 -
Want to retrieve multiple XML fragments in CLOBs in a *single query*
Hi,
I am trying to retrieve some well formed XML fragments stored as CLOBs from an 8i DB. For a single fragment at a time this is not a problem using <xsql:include-xml>. However, I am trying to retrieve multiple well formed fragments in a single query, "stacked" like so...
<xsql:include-xml>
<![CDATA[
select theXMLFrag from tclob1 where id = 'open'
union all
select theXMLFrag from tclob2 --returns multiple rows
union all
select theXMLFrag from tclob3 --some more rows
union all
select theXMLFrag from tclob1 where id = 'close'
]]>
</xsql:include-xml>
What I am really after are the contents from the middle two selects. (The 'open' and 'close' bit was just a cheap attempt to ensure that the included XML is well formed.) Though it is not shown in my example, the problem is that the number and source of the CLOB fragments is not known until run time, and I wanted to use a dynamic query to assemble the needed CLOBS...
I have since learned that <xsql:include-xml> returns the first column of the first row of the query result as parsed XML, either from a CLOB or a VARCHAR containing well-formed XML. So my attempt is no good... all but the first row are ignored.
Does anyone have any suggestions for a way to do this using the existing xsql tag library? Or will I need to create my own <xsql:action>?
Thanks,
Bob NugentHi,
Let me correct if i am right:
- Central Contract -> new concept of SRM 7.0. 1 contract which is visible and usable from ECC and SRM as well. (not available in SRM 5.0 - agree)
- GOA -> it exist in SRM 5.0 for sure! (we are currenlty using it for ECC procurement).
The solution what you are mentioned is good...but as you said only for SRM 70...we are in SRM 5.0 and we need solution for here. Do you have any idea?
Currently i am thinking about a new solution based on "standard" functionalities: if a GOA need to be created for mulitple company, it has to be populated in Header distribution (all company will have the same contract header). It item detail all the required information need to be poupulate in SRM (i.e.: item 1 for p.org1/comp.cod1; item 2 for p.org2/comp.cod2).
When this is done, the BADI need to check the informatoin in SRM GOA and create contract according to that -> in this case 1GOA is created, but the 2 items for totally different p.org/comp.code, the BADI needs to create 2 different contract in ECC (i would like to avoid using reference purchasing organization in ECC!
Thanks in advance!
Best Regards,
Attila -
Single query return multiple value
Hi ALL,
I have a sql query as below :
select order_number,
(select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id) Email
FROM oe_order_headers_all h
WHERE h.order_number='102'
Actually the problem i am facing is the inner select query is returning multiple row , so my main query is erroring out, i need to capture the multiple row.
in the above example the inner decode statement returning two mail address, i need to capture that, but while executing the whole query it is erroring out as saying single query returns multiple values.
please help me on this to capture multiple values
Thanks>
select order_number,
(select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id
/* a join is missing here that points to table oe_order_headers_all h*/) Email
FROM oe_order_headers_all h
WHERE h.order_number='102'
>
I can see a join missing in your select sub query.
However, if you you are still getting the single query return multiple value error then you need to replace the sql sub query
select decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
from hz_contact_points,
hz_parties hz
WHERE hz.party_id=hcp.owner_table_id)by decode(hcp.contact_point_purpose,'ABC',hcp.email_address,'CDE',hcp.email_address,null)
and join the two tables in you main query..
Regards
Biju
ED: Provide test script and your expected output to get what you want exacly!
Edited by: biju2012 on Sep 7, 2012 12:06 AM -
Updating multiple node in a single query
Hi
Shall I update multiple nodes (which satisfies the given condition) in a single query? From the prototype we suspect that all nodes in all document are not updated in the container.
Version: BDB XML 2.4 - Fedora core 4 Linux - C++ language
Query:
replace value of node collection()/File[@Id="57565C01327A"]//Entry[@Class="Measurement" and @Id="0"]/Attribute[@Name="apDlBhUtil"]/@Value with 8'
Result:
XmlException occurred with msg 'Error: Sequence does not match type node() - the sequence contains more than one item [err:XUTY0008], <query>:1:1'
We have tried running the query in both Lazy and Eager evaluation type. Please clarify that the issue is with the query/execution type or BDB XML doesn't support this feature?
Thanks
SanthoshSanthosh,
Try:
for $i in collection()/File[@Id="57565C01327A"]//Entry[@Class="Measurement" and @Id="0"]/Attribute[@Name="apDlBhUtil"]/@Value return replace value of node $i with 8'The problem with your original is that the argument for "replace value of" needs to be a single item, not a sequence.
Regards,
George -
Multiple conditin on a single column in a single query
i want to select data from the table using diff conditions on a single column
for eg:
i need emp details like whose having empno as 5-15,19-45,50-89 ..etc this how can i give a condition in a single query
we can use in or between for 2 or 3 conditions but i have plenty off like thisHi,
848525 wrote:
i want to select data from the table using diff conditions on a single column
for eg:
i need emp details like whose having empno as 5-15,19-45,50-89 ..etc this how can i give a condition in a single query
we can use in or between for 2 or 3 conditions but i have plenty off like thisYou can use OR for any number of conditions; it works the same for 4 or more.
You could also put the ranges into a table (or a sub-query, as shown below) and join:
WITH empno_ranges AS
SELECT 3000 AS low_val, 5000 AS high_val FROM dual UNION ALL
SELECT 7000, 7499 FROM dual UNION ALL
SELECT 7500, 7599 FROM dual UNION ALL
SELECT 7800, 7899 FROM dual
SELECT r.*
, COUNT (e.empno) AS emp_cnt
FROM empno_ranges r
LEFT OUTER JOIN scott.emp e ON e.empno BETWEEN r.low_val
AND r.high_val
GROUP BY r.low_val, r.high_val
ORDER BY r.low_val
;Output:
LOW_VAL HIGH_VAL EMP_CNT
3000 5000 0
7000 7499 2
7500 7599 2
7800 7899 3 -
How to use multiple aggregate functions in single query
hi to all
The output will be giving first_name,last_name,max(salary),min(salary) and the output will be department wise.From employees table in single query
output will be:
first_name|last_name|max(salary)|min(salary)SELECT first_name||' '||last_name as ename,
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;Edited by: Ramio on Jan 10, 2012 10:43 PM -
How to calculate multiple aggregation in a single query
how to find firstname ,lastname for max and min salary from employees table group by department in a single query?
Edited by: Gnanasekar on Jan 10, 2012 6:36 AMcheck this query
select ENAME,SAL
from EMP
where SAL in(select max(SAL)
from EMP
group by DEPTNO)
or SAL in(select min(SAL)
from EMP
group by DEPTNO)Hope this will help you..
You should ask this question at sql/plsql forum
If someone's response is helpful or correct, please mark it accordingly. -
Single Query with multiple fiscal variants / fiscal period
Experts,
Currently we have two different queries 1) for US and 2) for Mexico.
Both the queries are hard-coded with respective company codes and different fiscal variants. We have i step =1 variable, so in both query we have respective fiscal period by default in variable screen. The user can decide to run the query for current fiscal period or manually overwrite it for past few fiscal periods.
Now, we want to consolidate two queries into a single one and behind the scene depending on company code entered by user we want the query to run for default period AND we also want user to have liberty to change it for different fiscal periods (similar to istep 1 variable) which is hard coded for each query. Please advice how to proceed?
Thanks!Hi Durgesh,
I agree with part 1- we can let user select his company code, but my challenge is pre-populate or get the default fiscal period for different company codes.
2) You can keep rest of the things as it is, because you will be populating the default period value and if user want he can select the required value manually.
(Alok) = So if user runs report in Nov'2011 = the US fiscal period is 002/2012; but for Mexico it might be 011/2011 - so is there any way where we can give this value in prompt screen and at the same time not let user remember these values...
Since with single query and without hardcoding how to determine the current fiscal period for different company codes?
Maybe you are looking for
-
Music file location. Trying to share music on same computer multiple users
THE FACTS!!: I have a iphone4 my wife has a iphone4 my son has a itouch4 we each have different apple id's we have one computer and all different user accounts on this same computer Yes I have gone into I tunes on all three user signon's and gone to
-
Just created a video - But can't see it - Tracks appear unchecked !
Help please ! Just put a few .mov files together in Quick Time Pro Version 7 downloaded a couple of days ago. (Save as one file not saved to collect from separate files). Looked good. Saved it. Then went to view again. Opened file - just get a strip
-
I updated to Mavericks yesterday and right now there is no app icons for some of the apps in the lauch pad and dock..
-
InDesign 5.5 changes Stories IDs on export document
I'm working on a project where part of the work involve InDesign templates. The rest of code calling elements from the InDesign templates refence them using IDs (IDML component name) - including files from /Stories subfolder of template and then read
-
Selecting listbox item with right mouse click
Hi, I have a listbox control with non editable items. Is there an easy way to select an item with a right mousebutton click (Like the left click) Solved! Go to Solution.