Can these two queries be combined
Is there a more eloquent way of joining the two tales to only
get those records that have more than one record. Instead of
writing two seperated queries, can one query achieve the
results?
Could this also have been solved with one query by just doing
the following?
<cfquery name="get_mult_posn" datasource="#dsn#">
SELECT a.posn_id, a.pers_id, a.job_titl, frst_name,
mid_name, last_name
FROM posntable a, perstable b
WHERE a.pers_id = b.pers_id
</cfquery>
Similar Messages
-
Joining these these two queries (one regular and one grouped)
Hello
I have these two queries I would like to join, however the later is a grouped query how can I join it with the first query?
Has to be joined on EventId. The second query is a total table scan.
SELECT AH.EventID,
AH.TechnicalAddress, AH.AlarmAlias, AH.AlarmPath as [OrgAlarmPath], AH.AlarmCounter as AlarmCount, AH.EventDateTime as EventTime,
AH.[Priority], AH.AlarmMessage, AH.EventText, AH.CallListName, AH.AlarmReadDate as EndTime,
AH.alh_EventEndedUserRemark as [EndRemark] --, SUM(seconds) here, and AlarmSessions here
FROM AlarmHistory AH
WHERE (AH.HeartbeatAlarm = 0 OR AH.HeartbeatAlarm IS NULL) AND
((AH.CallListID IS NOT NULL) OR (AH.alh_IsForStatistics = 1)) AND
(NOT (AH.alh_t_EventSubCode is NULL or AH.AlarmReadByUserID is NULL))
ORDER BY AH.EventID DESC
SELECT ia.eventID, SUM(DATEDIFF(SECOND,ia.eventTime,r.eventTime)) AS seconds, COUNT(*) as AlarmSessions
FROM alarmHistoryLog ia
INNER JOIN alarmHistoryLog r
ON ia.EventId = r.EventId
AND r.EventTypeId = 2
AND r.EventSeq = (SELECT MIN(eventSeq) FROM alarmHistoryLog WHERE eventSeq > ia.EventSeq AND EventTypeId = 2)
WHERE ia.EventTypeId = 0
group by ia.EventId
order by EventId desc
HenryTry the below:
;with ctefirst as
SELECT AH.EventID,
AH.TechnicalAddress, AH.AlarmAlias, AH.AlarmPath as [OrgAlarmPath], AH.AlarmCounter as AlarmCount, AH.EventDateTime as EventTime,
AH.[Priority], AH.AlarmMessage, AH.EventText, AH.CallListName, AH.AlarmReadDate as EndTime,
AH.alh_EventEndedUserRemark as [EndRemark] --, SUM(seconds) here, and AlarmSessions here
FROM AlarmHistory AH
WHERE (AH.HeartbeatAlarm = 0 OR AH.HeartbeatAlarm IS NULL) AND
((AH.CallListID IS NOT NULL) OR (AH.alh_IsForStatistics = 1)) AND
(NOT (AH.alh_t_EventSubCode is NULL or AH.AlarmReadByUserID is NULL))
), ctesecond as
SELECT ia.eventID, SUM(DATEDIFF(SECOND,ia.eventTime,r.eventTime)) AS seconds, COUNT(*) as AlarmSessions
FROM alarmHistoryLog ia
INNER JOIN alarmHistoryLog r
ON ia.EventId = r.EventId
AND r.EventTypeId = 2
AND r.EventSeq = (SELECT MIN(eventSeq)
FROM alarmHistoryLog WHERE eventSeq > ia.EventSeq AND EventTypeId = 2)
WHERE ia.EventTypeId = 0
group by ia.EventId
Select A.*,B.seconds,B.AlarmSessions From ctefirst A
Inner join ctesecond B On A.EventId = B.EventID
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog] -
Whats the difference between these two queries ? - for tuning purpose
Whats the difference between these two queries ?
I have huge amount of data for each table. its takeing such a long time (>5-6hrs).
here whice one is fast / do we have any other option there apart from listed here....
QUERY 1:
SELECT --<< USING INDEX >>
field1, field2, field3, sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end)
FROM
tab1 inner join tab2 on condition1 inner join tab3 on condition2 inner join tab4 on conditon3
WHERE
condition4..10 and
GROUP BY
field1, field2,field3
HAVING
sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end) <> 0;
QUERY 2:
SELECT --<< USING INDEX >>
field1, field2, field3, sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0))
FROM
tab1, tab2, tab3, tab4
WHERE
condition1 and
condition2 and
condition3 and
condition4..10
GROUP BY
field1, field2,field3
HAVING
sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0)) <> 0;
[pre]My feeling here is that simply changing join syntax and case vs decode issues is not going to give any significant improvement in performance, and as Tubby points out, there is not a lot to go on. I think you are going to have to investigate things along the line of parallel query and index vs full table scans as well any number of performance tuning methods before you will see any significant gains. I would start with the Performance Manual as a start and then follow that up with the hard yards of query plans and stats.
Alternatively, you could just set the gofast parameter to TRUE and everything will be all right.
Andre -
Hi experts,
I need to join two queries but not sure how:
select id from test_table1;
select *
from table(f_function(null
,null
,1 -- the id
,sysdate);One query has IDs needed to run the second query. Is there a way to join those two?
The result should be all columns from test_table1 + all columns from f_function.
Best regards,
Igor
Edited by: Igor S. on Mar 8, 2013 5:18 AMHi,
Igor S. wrote:
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
) xyz
where test_table1.id = xyz.id
/So these two queries are the same?Try it and see.
You'll find that the 2nd one produces an error. But if you change it to
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
) -- No alias here
) xyz -- Alias here, instead
where test_table1.id = xyz.id
/Then, assuming f_function produces a column called id, it will work.
Whether it produces the same results or not depends on what the function returns, and whether either id is NULL.
If the id column that the function returns is the same as the id value that you pass to it, and is never NULL, then the 2 queries will produce the same results.
Either way, each row of test_table1 will be joined to each row that the function produces with the argument(s) from that row. The column names produced by the function and the values in those columns are determined by the function; they do not need to have anything in common with any table. In practice, a function like f_function will usually not return an column that is always identical to any of its inputs, since that value is already available from the input. -
I have two queries. The First one is long but very simple. All it has is long list of columns.
First one:
SELECT CL.CLIENT_ID, CA.CASE_ID, to_char(SYSDATE,'RRMMDD'),
CL.MASTER_CLIENT_ID,
CL.NAME1,
nvl(CL.NAME2,' '),
nvl(CL.ADDRESS1,' '),
nvl(CL.ADDRESS2,' '),
CL.POCO_POSTAL_CODE, nvl(CL.CITY,' '),
nvl(CL.AUTO_SURV_CODE,0),
CA.Col_Collector_Id
FROM CLIENT CL, CASES CA
WHERE CA.CL_CLIENT_ID = CL.CLIENT_ID AND
CA.CASE_ID = :current_case_id
Second one:
SQL SELECT nvl(REF_NO,' '), nvl(to_char(DATE_OF_JUDGEMENT,'rrmmdd'),' ')
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8) AND
CA_CASE_ID = :current_case_id AND
PETITION_DATE = (SELECT max(PETITION_DATE)
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8)
AND CA_CASE_ID = :current_case_id
AND ROWNUM < 2 );
The :current_case_id is passed as a parameter. The table in the second query i.e. CASE_INSTANCES is related to the first query with the CA_CASE_ID. Not all records fetched by the first query have a record in the second query. So you might have to use a LEFT JOIN or something. trying to join these two has worn me out. Please help me out someone.Hi,
Simplified Solution:
SELECT * FROM (
SELECT CL.CLIENT_ID, CA.CASE_ID, TO_CHAR(SYSDATE,'RRMMDD'),
CL.MASTER_CLIENT_ID,
CL.NAME1,
NVL(CL.NAME2,' '),
NVL(CL.ADDRESS1,' '),
NVL(CL.ADDRESS2,' '),
CL.POCO_POSTAL_CODE, NVL(CL.CITY,' '),
NVL(CL.AUTO_SURV_CODE,0),
CA.Col_Collector_Id
FROM CLIENT CL, CASES CA
WHERE CA.CL_CLIENT_ID = CL.CLIENT_ID ) a,
(SELECT NVL(REF_NO,' '), NVL(TO_CHAR(DATE_OF_JUDGEMENT,'rrmmdd'),' '),CA_CASE_ID
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8) AND
CA_CASE_ID = :current_case_id AND
PETITION_DATE = (SELECT MAX(PETITION_DATE)
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8)
AND CA_CASE_ID = :current_case_id
AND ROWNUM < 2
) b
WHERE a.case_id = b.ca_case_id(+)
Regards
K.Rajkumar -
These two queries return same data?
select * from voucher where (unit = 'TIA4M' or unit = 'TIAFM' or unit = 'TIAWM' or unit = 'TIATW' or unit = 'TIAPA' )
and invoice_dt >= TO_DATE('01/01/2006', 'MM/DD/YYYY')
select * from voucher where unit in ('TIA4M', 'TIAFM', 'TIAWM', 'TIATW', 'TIAPA')
and invoice_dt >= TO_DATE('01/01/2007', 'MM/DD/YYYY')
Also the first is much faster right?The first query is using a date of Jan 1, 2006. The second query is using a date of Jan 1, 2007.
Assuming that is a typo, the two queries are semantically identical. Since Oracle can easily transform an IN-list to a series of OR's, though, I would doubt that there would be any performance difference between them absent the 2006/2007 change.
Justin -
How do I join together these two queries?
Hi I have these queries:
select br_no, br_managersname from BRANCH order by br_managersname;
select sum(rent_endkms-rent_startkms) as "TOTAL KMS TRAVELLED" from RENTAL group by BR_NO having SUM(rent_endkms-rent_startkms) = (select MAX(sum(rent_endkms-rent_startkms)) from RENTAL group by BR_NO);
They each output their own tables, but I wanna join them together so they output as one table. Unfortunately, I really suck at joining tables. Can anyone help?Hmm... Not enought information again... Any way, let me consider br_no as the key between the two query. In that case i came up with this.
with query1
as
select br_no, br_managersname
from BRANCH order by br_managersname
query2
as
select br_no, sum(rent_endkms-rent_startkms) as total_kms_travelled
from RENTAL
group by BR_NO
having SUM(rent_endkms-rent_startkms) = (select MAX(sum(rent_endkms-rent_startkms))
from RENTAL
group by BR_NO)
select q1.bar_no, q1.br_managersname, q2.total_kms_travelled
from query1 q1
join query2 q2
on q1.br_no = q2.br_no -
Can these two attributes conflict each other?
A Data Guard question: Can MAX_FAILURE and NET_TIMEOUT attributes conflict each other if we configure them simultaneously on a same LOG_ARCHIVE_DEST destination?
Is there any overlap to them?Is it easier to ask someone else to look up the
answer for you than to look it up yourself?
http://www.oracle.com/pls/db111/homepage
I encourage you to read it for yourself. You might
just learn something else of value.
Read the Doc - A Poem
I need a guru who can do
In one statement - a line or two,
To write for me the fix i need
to make me a hero, o yes indeed.
I hack and I paste, can't show my true code
But using your powers I'm sure you will know
What is my issue, time is flying - Tick-Tock...
What do you mean, just go read the doc? RTFM - right? ;} -
I Hope someone can help me! I have an I-Pad and a mini I- Pad.
Both have identical content, e-mail , etc. How can I or what can be done to make them 2 separate I -Pads so that I can erase the content from one but not the other.
As it is now , if I. delete anything from one,the same is deleted from the other. What action can be performed to make them separate entities.
thank you for your help in this matterHi If you want to you can put one ipad back to factory settings Before you do this in settings turn off find my iPhone Then you can set ipad up as new. But if you use the same Apple ID you will get the sameApps & data back on again. Cheers Brian
-
Can these two functionalities work on datagrid?
Hi everyone,
I have a datagrid (shopping card) which has 3 columns such as
ProductName, Quantity, Details.
Part 1: Once the user click on the Quantity, then the user is
allowed to make changes on the quantity.
Part 2: Once the user click on the Details, then the code
will get to another state which shows the product details.
Part 1 is done. But Part is is not done yet. Any idea how to
get Part 2 done is greatly appreciated. Thanks.
Note for Part 2. If the user click on the Details on row 1,
then the code show product 1 details. If the user click on
Details on row 2, then the code show product 2 details, ...
etc.
Thanks,
Mayquote:
Originally posted by:
Mirza Asim
in the 'itemEditBegin' event handler, if 'event.columnIndex'
is the index of 'Detail' column, then take the row of dataProvider
at the index 'event.rowIndex' and do whatever you want with it. If
you want to change the state then change the state and pass this
information of row data to that state.
I tried my best to understand your question and then replied
accordingly. But if my answer is not very clear to you then please
tell me, what exactly you want.
Hi Mirza,
Thanks for your help. Yes what you are saying is exactly what
I want to do. But I cannot change the state (see LINE XYZ). Please
see the code and error message below. Thanks.
May
// Handle the itemEditBegin event.
private function modifyEditedData(event:DataGridEvent):void
// Get the name of the column being editted.
var colName:String =
myDataGrid.columns[event.columnIndex].headerText;
if(colName=="Product Details")
trace(_myShoppingCardArrayCollection.getItemAt(event.rowIndex).ProductCode);
_productCode_temp =
_myShoppingCardArrayCollection.getItemAt(event.rowIndex).ProductCode;
//currentState = "ProductDetailsFromShoppingCard"; //<==
This line gives error (LINE XYZ).
private function updateQuantity():void {
var iQty:int = 0;
var qty:String = "";
for (var
i:int=0;i<_myShoppingCardArrayCollection.length;i++) {
trace(_myShoppingCardArrayCollection.getItemAt(i).Quantity);
qty += _myShoppingCardArrayCollection.getItemAt(i).Quantity
+ "\r";
iQty +=
parseInt(_myShoppingCardArrayCollection.getItemAt(i).Quantity);
trace("Qty:" + iQty)
Alert.show(qty);
<mx:DataGrid id="myDataGrid"
dataProvider="{_myShoppingCardArrayCollection}"
editable="true"
itemEditBegin="modifyEditedData(event);"
rowHeight="60">
<mx:columns>
<mx:DataGridColumn headerText="Product Name"
dataField="ProductName" textAlign="left" wordWrap="true"
editable="false" />
<mx:DataGridColumn headerText="Product Price"
dataField="ProductPrice" textAlign="center" editable="false" />
<mx:DataGridColumn headerText="Quantity"
dataField="Quantity" editable="true" />
<mx:DataGridColumn headerText="Product Details"
dataField="ProductCode" editable="true" />
</mx:columns>
</mx:DataGrid>
<mx:Button label="Update" click="updateQuantity()" />
--------------------------------- end --------------------
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at
mx.controls::DataGrid/createItemEditor()[E:\dev\3.0.x\frameworks\projects\framework\src\m x\controls\DataGrid.as:3884]
at
mx.controls::DataGrid/itemEditorItemEditBeginHandler()[E:\dev\3.0.x\frameworks\projects\f ramework\src\mx\controls\DataGrid.as:4747]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co re\UIComponent.as:9051]
at
mx.controls::DataGrid/commitEditedItemPosition()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\controls\DataGrid.as:3676]
at
mx.controls::DataGrid/updateDisplayList()[E:\dev\3.0.x\frameworks\projects\framework\src\ mx\controls\DataGrid.as:1498]
at
mx.controls.listClasses::ListBase/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\ framework\src\mx\controls\listClasses\ListBase.as:3281]
at
mx.managers::LayoutManager/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:602]
at
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:675]
at Function/
http://adobe.com/AS3/2006/builtin::apply()
at
mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
at
mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick() -
How to combine two queries in one EXCEL
hi i got one requirement
i got one excel sheet from user which contains two report s(hoe we know whether it is worknook or not) of 2011 data and now user wants 2012 data .now i icluded jan 2012 to dec 2012 in two reports and sent to user.But user is asking these two reports want to see in one sheet.
so how can i proceed: if i go for work book how can i include these two reports in workbook and here my doubt is if i create a workbook based on these two querie which name i have to give user.Please help me out on the same.
Regards,
Madhu.Hi Madhu
Run one query. Click on a empty space in the excel
From the BEx Design Toolbar -
>Insert Analysis Grid -
> Right click on the Design Item
Edit the DataProvider.....You can ran same or different query with selection.
Save the result
Check this link for detail....I am also searching for something with screenshot
Regards
Anindya
Edited by: Anindya Bose on Feb 14, 2012 3:04 AM -
How to Combine two queries into One
Hi Gurus,
SQL> select * from v$version;
BANNER
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL>
I have following two queries. How I can convert these two queries into one with the same result ?
Q1
SELECT id,vdate,vendorname,venddate,vid
FROM VENDOR
WHERE processid=32
AND venddate is null
AND vid in(select vid from view_vid where type='PDX')
AND (id,vdate) not in (select id,vdate from vkfl_is where task_id=55)
AND (id,vdate) in (select id,vidate from market_data where marketed_date is null)
AND id not in (select id from location)
Q2
SELECT id,vdate,vendorname,venddate,vid
FROM VENDOR
WHERE processid=20
AND venddate is null
AND vid in(select vid from view_vid where type='PBX')
AND (id,vdate) not in (select id,vdate from vkfl_is where task_id=40)
AND (id,vdate) in (select id,vidate from market_data where region_date is null)
AND id not in (select id from location)
I can UNION these two queries, but, is there any way I can write a single query with which gives me same result as above two queries?
Any help would be highly appreciated
Thanks in advanceHi,
You can do something like this, which will be more efficient than a UNION:
SELECT id, vdate, vendorname, venddate, vid
FROM vendor
WHERE ( ( -- Conditions that apply only to q1
processid = 32
AND vid IN (SELECT vid FROM view_vid WHERE type = 'PDX')
AND (id,vdate) NOT IN ( SELECT id, vdate
FROM vkfl_is
WHERE task_id = 55
AND (id,vdate) IN ( SELECT id, vidate
FROM market_data
WHERE marketed_date IS NULL
OR ( -- Conditions that apply only to q2
processid = 20
AND vid IN (SELECT vid FROM view_vid WHERE type = 'PBX')
AND (id,vdate) NOT IN ( SELECT id, vdate
FROM vkfl_is
WHERE task_id = 40
AND (id,vdate) IN ( SELECT id, vidate
FROM market_data
WHERE region_date IS NULL
-- The remaining conditions apply to both q1 and q2
AND venddate IS NULL
AND id NOT IN (SELECT id FROM location)
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Query 1 show me a list of users, each user should tell me how many orders, how many row, and total amount they placed <b>for a certain date</b>.
Query 2 show me again a list of user, each user should me how many orders and how many row they placed <b>excluding that date above that are still open</b>.
I would like these two queries to show on one report. Is it possible?
Query 1:
SELECT COUNT(DISTINCT T0.UserSign) AS 'Today_order',
COUNT(T1.PickStatus) AS 'Today_row', SUM(T1.Price *
T1.OpenQty) AS 'Today_amount' FROM [dbo].[RDR1] T1
INNER JOIN [dbo].[ORDR] T0 ON T1.DocEntry = T0.DocEntry
WHERE <b>T0.DocDate = CONVERT(DATETIME, '20051109', 112)</b>
AND T1.OpenQty > 0
Query 2:
SELECT COUNT(DISTINCT T0.UserSign) AS 'Other_order',
COUNT(T1.PickStatus) AS 'Other_row' FROM [dbo].[RDR1]
T1 INNER JOIN [dbo].[ORDR] T0 ON T1.DocEntry =
T0.DocEntry WHERE T1.OpenQty > 0 AND <b>T0.DocDate <>
CONVERT(DATETIME, '20051109', 112)</b>Hi Laura,
It's probably easiest to use temporary tables or a cursor for this query.
This code works for me (in SQL Query Analyzer and SBO):
set nocount on
create table #users (UserSign int, UserName nvarchar(30))
create table #today (UserSign int, Today_row int, Today_amount numeric(15, 2))
create table #other (UserSign int, Other_row int)
insert into #users
select T0.USERID, T0.U_NAME from OUSR T0
insert into #today
SELECT DISTINCT T0.UserSign AS 'Today_order',
COUNT(T1.PickStatus) AS 'Today_row', SUM(T1.Price *
T1.OpenQty) AS 'Today_amount'
FROM [dbo].[RDR1] T1
INNER JOIN [dbo].[ORDR] T0 ON T1.DocEntry = T0.DocEntry
WHERE T0.DocDate = CONVERT(DATETIME, '20051109', 112)
AND T1.OpenQty > 0
GROUP BY T0.UserSign
insert into #other
SELECT DISTINCT T0.UserSign AS 'Other_order',
COUNT(T1.PickStatus) AS 'Other_row' FROM [dbo].[RDR1]
T1 INNER JOIN [dbo].[ORDR] T0 ON T1.DocEntry =
T0.DocEntry WHERE T1.OpenQty > 0 AND T0.DocDate <>
CONVERT(DATETIME, '20051109', 112)
GROUP BY T0.UserSign
set nocount off
select T0.UserSign, T0.UserName, isnull(T1.Today_row, 0) as Today_row,
isnull(T1.Today_amount, 0) as Today_amount,
isnull(T2.Other_row, 0) as Other_row
from
#users T0 left outer join #today T1 on T0.UserSign = T1.UserSign
left outer join #other T2 on T0.UserSign = T2.UserSign
drop table #users
drop table #today
drop table #other
I've added the user name from the OUSR table to make the query a bit easier to understand.
Hope this helps,
Owen -
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
_1st query_
select
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END) Landlord
,TO_CHAR(C1.COLL_DTE,'RRRRMM') MONTH1
,SUM(C2.TRN_AMT) UPTO_31
, SUM(CASE WHEN to_char(C1.COLL_dte) BETWEEN to_date(:P_FROM_DATE,'dd.mm.yyyy') AND '16-'||to_date(:P_TO_DATE,'dd.mm.yyyy') THEN C2.TRN_AMT END) UPTO_15
from ra1 R1, COLLECT1 C1 , COLLECT2 C2
where
(to_char(C1.COLL_dte) between to_date(:P_FROM_DATE,'dd.mm.yyyy') AND to_date(:P_TO_DATE,'dd.mm.yyyy'))
and (SUBSTR(R1.RA_NO,1,2)= 'FR' or SUBSTR(R1.RA_NO,1,3) in ('NRA' ,'ORA','VRA','URA','WRZ'))
AND R1.RA_NO = C2.INV_NO
AND C2.COLL_NO = C1.COLL_NO
GROUP BY
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END)
,TO_CHAR(C1.COLL_DTE,'RRRRMM')
_2query_
select sum(decode(substr(ra_no,1,7),'NRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) NRA
,sum(decode(substr(ra_no,1,7),'VRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) VRA
,sum(decode(substr(ra_no,1,7),'ORA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) ORA
,sum(decode(substr(ra_no,1,7),'FR'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) FR
,sum(decode(substr(ra_no,1,7),'WRZ'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) WRZ
,sum(decode(substr(ra_no,1,7),'URA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) URA
from RA1
above are the two queries i need to join these two queries by naming the second query column name as total .1st query output is ----------
LOCATION MONTH1 UPTO_31 UPTO_15
U5 Management Corporation Sdn. Bhd. 201001 15250 8900
Uptown Elite Sdn. Bhd. 201001 3000 1500
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6
2nd query output is -------
NRA ORA VRA URA WRZ FR
2323.31 95945 34367.8 34267 4343 343
Now what i need is
LOCATION MONTH1 UPTO_31 UPTO_15 TOTAL
U5 Management Corporation Sdn. Bhd. 201001 15250 8900 2323.31
Uptown Elite Sdn. Bhd. 201001 3000 1500 95945
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5 34367.8
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95 34267
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45 4343
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6 343above is the clear picture what i need , i don't know how to do it please help me
Edited by: user9093689 on Feb 21, 2010 8:06 PM -
Two queries in one output in BEx is it possibl ?
Hi,
Is there a possibility in Bex Excel screen that we can output two queries at the same time , like 1st query in first half and second query 2nd half of the screen .I think its not possible but just wanna know if anyone came across such an issue
I know it is possible with WAD ...Hi Raj,
You can execute 2 queries in one work book.First execute one query,place the cursor under query results area,go to tools->Insert query->execute.Save->Save existing work book.
When ever u open the work book u have to execute both the queries.Instead of executing twice you can use some options, so that it saves and reuses the input values and automatically refresh the queries when u open the work book(If the input values are fixed).
For that right click->Properties->Intraction tab
You can see 4 check boxes.check all boxes,ok for all queries and save.So when u open the work book it retrieves data.No need to give input values
Maybe you are looking for
-
Why is my iCloud storage full when I bought a 32GB iPad mini?
When my mum bought me my iPad mini at Christmas (7 months ago), she bought me a 32GB and recently I have had notifications saying that my iCloud storage is full. I have deleted many apps and many photos, also when I try to delete the data of certain
-
When I go to edit a picture from Lightroom to Photoshop it does not open in Photoshop, it use to work before the latest update, but I deleted the last version of Photoshop CC and now it isn't editing photos! Lightroom opens up Photoshop but the image
-
Does platform affect report performance?
Hi We have a report that is currently run on a unix reports server. It completes within 3 minutes , sometimes 5. We moved this to a windows based reports server, this takes more than an hour. I tried to run this on my local report builder on windows
-
Can a wallpaper image be forced to occupy the whol...
I cropped down a photograph in Photoshop that I wanted to use as a wallpaper image on my 6220 classic and saved it so that it was 320 pixels tall by 240 pixels wide - the same resolution as the screen on the phone. However when I copy it to the phone
-
Help with syncing iPod Nano to iPad
I have an iPod Nano purchased in March 2013 and want to transfer my music from the Nano onto my hubby's iPad, purchased December 2012, how do I do it? Ive tried syncing the iPad to iTunes on my laptop and it doesnt work. Ive never known such a compl