Grouping on same table
Hello All,
Our oracle version is 9i on linux.
Our application has most of the queries styled as below ,
select
from
act A ,
best B
where a.id = b.id
and b.end_dt = (
select max(end_dt)
from best BB
where b.id = bb.id
Is there anyway i can avoid the sub query as the sub query logic is the reason for slowing of most queries.
Also one query in the same structure takes nested loop with RULE hint and with out hint it gives Cartesian join in addition to nested loop.
Thanks in advance ,
vijay G
Hi, Vijay S P G
try this, please, I dont tested this code.
SELECT A.ID AID,
B.ID BID,
B.END_DT,
B.MAX_END_DT
FROM ACT A ,
(SELECT ID,
END_DT,
MAX(END_DT) OVER (PARTITION BY ID ORDERBY ID) MAX_END_DT
FROM BEST) B
WHERE A.ID = B.ID
AND B.END_DT = B.MAX_END_DT
Similar Messages
-
How to group together same field values in a internal table.
Hi Gurus,
Case:1
Using AUFNR, i am retrieving data from RESB table.
Fields (RSPOS, ALPGR, ALPRF,KZAUS, MATNR).
If RESB-ALPGR (Alternate material group) is not initial, sort those values with ALPFR (Priority) after that group together same ALPGR values.
1) Top most priority (ALPRF) value MATNR populate to IDOC field.
2). Next top priority (ALPRF) value MATNR populate to IDOC field.
Case2:
using AUFNR, check RESB-KZAUS if it has a value '1'.
then, check to see if there are RESB-RSPOS that has the same (repeated RSPOS values) Ex: RSPOS value 0002,0002.
if yes, place the first RSPOS with KZAUS = 1. MATNR move to IDOC next RSPOS-MATNR value move to IDOC field.
Points will be awarded for useful answers.
Thanks in Advance.
Sashi.Hi,
Check this Example..
DATA:BEGIN OF ITAB OCCURS 0,
NAME(15) TYPE C,
END OF ITAB.
ITAB-NAME = 'peter'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME = 'john'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME = 'abrahm'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME = 'daneyal'.
APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-NAME.
ENDLOOP.
Reward Points if found helpfull..
Cheers,
Chandra Sekhar. -
Two LOVs in same UIX page based on the same table
Hi group,
Recently I ran into a problem with a UIX page that has two LOVs based on the same database table. In Emp and Job terminology, here's what I tried to do.
Suppose we have use the Employees and Jobs tables from the HR scheme with one small modification. Add a column called PREFERRED_JOB_ID of type VARCHAR2(10) which is exactly the same as JOB_ID. Hypothetically speaking, this column will be used to allow Employees to select their preferred job in case they want to change their jobs.
Next, create business components in JDeveloper based on the Employees and Jobs table. In order to be able to generate the LOVs for Job and PreferredJob create two ViewObjects, one called JobsLookupView and one called PreferredJobsLookupView. These both need to be based upon the same Jobs EntityObject. Also include the Jobs EntityObject twice in the EmployeesView ViewObject and give one the alias PreferredJobs. Include the JobTitle attributes of Jobs and PreferredJobs in EmployeesView so they can contain the JobTitles selected in our future LOVs.
Next create a ViewController project if it's not already there and enable JHeadstart on it. Create an Application Structure File and create the lookups for the two LOVs. When I run the application I see this happening:
When I click the flashlight icon next to the PreferredJob LOV and select a job, the PreferredJob field is selected in the UIX page but no job title appears. When I next first select the Job LOV and select a new job and then select the PreferredJob LOV again and select a different job, the job that was selected in the Job LOV is now also entered in the PreferredJob field. When I make sure the PreferredJob field isn't required (remove the required="yes" property on the messageLovInput entry for PreferredJobTitle and remove the PreferredJobTitle field from the addRequiredRowItems list in the UIX page) I can save the changes I made in the Employees.uix page. The same JobId is stored in the database for Job and PreferredJob.
This behaviour is probably due to cacheing issues because both LOVs and the EmployeesView ViewObject use one EntityObject for four values in three ViewObjects.
So I then modified my model a bit. I created a new EntityObject called PreferredJobs based on the JOBS table. I modified the EmployeesView ViewObject to use this EntityObject for the PreferredJobTitle attribute and modified the PreferredJobsLookupView to use this EntityObject.
I needed to modify a few things as well in the Application Structure File (which were prompts and whether or not the attribute should be visible in a table) and after regenerating I made sure the PreferredJob attribute isn't required in the UIX page. When I then run the application again, I never see the JobTitle I select in any LOV allthough the PreferredJob field is selected when I select a Job in the PreferredJob LOV. The correct JobId now is stored in the database though.
Has anyone ever encoutered this behaviour? Would anyone know how to get two LOVs based on the same table in one UIX page?
Thanks in advance,
Wouter van Reeven
AMISOK I figured it out. When I added the second Lookup ViewObject (PreferredJobs) no additional Association was created. Therefore, ADF BC wasn't able to figure out which field to update. When I added the Association between the PreferredJobs Lookup ViewObject and the Employees ViewObject everything started working ok.
I then recreated my inital situation: one EntityObject for Jobs and one for Employees, now with two Associations between them. After modifying the Employees ViewObject and making sure the Jobs EntityObject was referred twice and via the corresponding Association, everything started working ok.
Greets, Wouter
AMIS -
How to sum different column in the same table
Hi everyone
I would like to know how can I make the sum of different column in the same table using apex
exple:
TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
thanks for reading me and I hope to hear from you soonHi,
Your question do not have anything do with APEX.
It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
You need have GROUP BY when you use aggregate functions like SUM.
I assume you like just add two columns.
Try
SELECT ENTPIDFISC
,EXEANNEE
,PROJBILTRIMT1PREV
,PROJBILTRIMT2PREV
,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
FROM TR_PROJ_BIL_TRIM
Regards,
Jari -
SUM two ROWS in the SAME Table
Hi,
I have a problem with this issue. I want to sum two rows from the same table, but I don´t know how to do that. I tried to do it with CTE, but always I get the same error "Ambiguous". I would like to ask you, if there is other manner to get that
data (sum two rows) and if it is possible to see examples about it.
Thank you in advanceHi Vaibhav,
I leave you my scrip:
USE Modelling
GO
--TABLE Aer_Lingus_Income_Statement
IF OBJECT_ID('Aer_Lingus_Income_Statement') IS NOT NULL
DROP TABLE Aer_Lingus_Income_Statement
GO
CREATE TABLE Aer_Lingus_Income_Statement
ID [nvarchar](255) NOT NULL,
Name_Account [nvarchar](255) NULL,
Company [nvarchar](255) NULL,
Level0_Account [nvarchar](255) NULL,
Level1_Account [nvarchar](255) NULL,
Level2_Account [nvarchar](255) NULL,
Level3_Account [nvarchar](255) NULL,
Level4_Account [nvarchar](255) NULL,
Level5_Account [nvarchar](255) NULL,
Level6_Account [nvarchar](255) NULL,
Level7_Account [nvarchar](255) NULL,
Level8_Account [nvarchar](255) NULL,
Year_2006 decimal (15,2) null,
Year_2007 decimal (15,2) null,
Year_2008 decimal (15,2) null,
Year_2009 decimal (15,2) null,
Year_2010 decimal (15,2) null,
Year_2011 decimal (15,2) null,
Year_2012 decimal (15,2) null,
Year_2013 decimal (15,2) null,
GO
ALTER TABLE Aer_Lingus_Income_Statement
ADD CONSTRAINT PK_Aer_Lingus_Income_Statement PRIMARY KEY (ID)
GO
INSERT INTO Aer_Lingus_Income_Statement
SELECT *
FROM Aer_Lingus_data_Income
IF OBJECT_ID('Aer_Lingus_Income_Statement_Historic') IS NOT NULL
DROP VIEW Aer_Lingus_Income_Statement_Historic
GO
CREATE VIEW Aer_Lingus_Income_Statement_Historic
as
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Revenue'
Group by Level0_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Passenger revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Ancillary revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Other revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Cargo revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Operating expenses'
Group by Level0_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Staff costs' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Depreciation, amortisation and impairment' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Aircraft operating lease costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Fuel and oil costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Maintenance expenses' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Airport charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='En-route charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Distribution costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Ground operations, catering and other operating costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Other (gains)/losses - net' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Employee profit share' and Level0_Account ='Operating expenses'
Group by Name_Account
GO
WITH sumasRevenue
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Revenue'
GROUP BY Name_Account, ID
WITH ROLLUP
, total
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasRevenue
WHERE Name_Account IS NULL
sumasOperatingExpensive
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Operating expenses'
GROUP BY Name_Account, ID
WITH ROLLUP
, total1
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasOperatingExpensive
WHERE Name_Account IS NULL
SELECT distinct ID , s.Name_Account,
(s.Y2006* 1.0 - t.Y2006) AS [V2006] ,(s.Y2007* 1.0 -T.Y2007 ) as [V2007] , (s.Y2008* 1.0 /T.Y2008 ) as [V2008],(s.Y2009* 1.0 /T.Y2009 ) as [V2009],
(s.Y2010* 1.0 /T.Y2010 ) as [V2010],(s.Y2011* 1.0 /T.Y2011 ) as [V2011],(s.Y2012* 1.0 /T.Y2012 ) as [V2012],(s.Y2013* 1.0 /T.Y2013 ) as [V2013]
FROM sumasRevenue AS s , sumasOperatingExpensive AS t
Where ID IS NOT NULL
UNION ALL
SELECT distinct ID,COALESCE(s.Name_Account,'NON CURRENT ASSETS') AS Name_Account ,
sum (s.Y2006* 1.0 / t.Y2006) as V2006,sum (s.Y2007* 1.0 / t.Y2007) as V2007,sum (s.Y2008* 1.0/ t.Y2008) as V2008,sum (s.Y2009* 1.0/ t.Y2009) as V2009,sum (s.Y2010* 1.0/ t.Y2010) as V2010,
sum (s.Y2011* 1.0 / t.Y2011) as V2011,sum (s.Y2012* 1.0/ t.Y2012) as V2012,sum (s.Y2013* 1.0/ t.Y2013) as V2013
FROM sumasRevenue as s , sumasOperatingExpensive as t
Where ID IS NULL and Name_Account IS NULL
GROUP BY Name_Account, ID
WITH ROLLUP
select *
from Aer_Lingus_Income_Statement_Historic
Thank you in advance -
Want to select individual data as well as aggregate data from the same table
want to select a, b from tab1 also need to find in the same table tab1 need to do sum(b) group by a
SELECT a,b,0 AS Ord
FROM tab1
UNION ALL
SELECT a,SUM(b),1
FROM tab1
GROUP BY a
ORDER BY a,Ord
assuming SQL Compact
If its SQL Server then we have much simpler methods
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Compare two results from the same table
i have two results from the same table that i would like to compare. below is my query and the results i want to compare
SELECT tblItemRoutingBOM.ItemRevID, tblItem.ItemID, tblItem.PartNum, tblItem.ItemName, tblItem.ManufacturerPartNum AS [Mfg Part#], tblItemRoutingBOM.Quantity
FROM tblItemRouting
INNER JOIN tblItemRoutingBOM ON tblItemRouting.ItemRoutingID = tblItemRoutingBOM.ItemRoutingID
INNER JOIN tblItem ON tblItemRoutingBOM.ItemID = tblItem.ItemID
WHERE tblItemRoutingBOM.ItemRevID in (61,70)
as you can see i am returning two records using the where clause
ItemRevID, ItemID, PartNum, ItemName, Manufacturer, Mfg Part#, Quantity
61,121,331503,.233 Aluminum Sheet,,1
70,121,331503,.233 Aluminum Sheet,,3
now what i am looking for is to combine these two together into one row with the following added. two columns for each QTY, QTY1 = 1 and QTY2 = 3 with a third column added that is the difference between the two QTY Diff = 2
Any thoughts?Here are the two statements that i want to combine, results for each are attached
SELECT tblItem.ItemID, Sum(tblItemRoutingBOM.Quantity) AS SumOfQuantity, tblItem.PartNum AS [Part #],
tblItem.ItemName, tblManufacturer.ManufacturerName AS Manufacturer, tblItem.ManufacturerPartNum AS [Mfg Part#]
FROM tblItemRouting
INNER JOIN tblItemRoutingBOM ON tblItemRouting.ItemRoutingID = tblItemRoutingBOM.ItemRoutingID
INNER JOIN tblItem ON tblItemRoutingBOM.ItemID = tblItem.ItemID
INNER JOIN tblUnits ON tblItem.UnitID = tblUnits.UnitID
LEFT JOIN tblManufacturer ON tblItem.ManufacturerID = tblManufacturer.ManufacturerID
WHERE tblItemRoutingBOM.ItemRevID=61
GROUP BY tblItem.ItemID,tblItem.PartNum,tblItem.ItemName,tblManufacturer.ManufacturerName,tblItem.ManufacturerPartNum
SELECT tblItem.ItemID, Sum(tblItemRoutingBOM.Quantity) AS Quantity, tblItem.PartNum AS [Part #],
tblItem.ItemName, tblManufacturer.ManufacturerName AS Manufacturer, tblItem.ManufacturerPartNum AS [Mfg Part#]
FROM tblItemRouting
INNER JOIN tblItemRoutingBOM ON tblItemRouting.ItemRoutingID = tblItemRoutingBOM.ItemRoutingID
INNER JOIN tblItem ON tblItemRoutingBOM.ItemID = tblItem.ItemID
INNER JOIN tblUnits ON tblItem.UnitID = tblUnits.UnitID
LEFT JOIN tblManufacturer ON tblItem.ManufacturerID = tblManufacturer.ManufacturerID
WHERE tblItemRoutingBOM.ItemRevID=70
GROUP BY tblItem.ItemID,tblItem.PartNum,tblItem.ItemName,tblManufacturer.ManufacturerName,tblItem.ManufacturerPartNum
114,11,55002,Pepsi Blue Cap,NULL,
117,5,331501,Marigold Yellow For ABS,NULL,
121,1,331503,.233 Aluminum Sheet,NULL,
125,2,331504,Velvet Vinyl .008,NULL,
114,33,55002,Pepsi Blue Cap,NULL,
117,15,331501,Marigold Yellow For ABS,NULL,
121,3,331503,.233 Aluminum Sheet,NULL,
125,6,331504,Velvet Vinyl .008,NULL,
my returned result should combine above with two extra columns (two extra columns because i have two results to combine)
114, 11, 33, 22, 55002, Pepsi Blue Cap, NULL,
117, 5, 15, 10, 331501, Marigold Yellow For ABS, NULL
121,1, 3, 2, 331503, .233 Aluminum Sheet, NULL
125, 2, 6, 4, 331504, Velvet Vinyl .008, NULL
Columns go as such, ID, QTY1 (for 61), QTY2 (for 70), Diff (QTY1-QTY2), PartNum, ItemName, Mfg, Mfg Part#
IF the results from one of those two are empty then i would see something like this
114, 11, 0, 11, 55002, Pepsi Blue Cap, NULL,
117, 5, 0, 5, 331501, Marigold Yellow For ABS, NULL
121,1, 0, 1, 331503, .233 Aluminum Sheet, NULL
125, 2, 0, 2, 331504, Velvet Vinyl .008, NULL -
Material Group Difference MM03 (Table MARA) and Reservation (Table RESB)
Why material group at T-code MM03 (MARA-MATKL) difference at Table RESB ?
Table MARA-MATKL = 04
Table RESB-MATKL = 02
I checking MM03 not change about material group. I don't know some T-code can change material group link to table RESB.Dear Mr.Jutamas,
As per to my understanding,initially when the reservation was made for the
particular material ,material group - 02 in Basic Data 1 view would have been
present or maintained in the material master.
After that a change might have occured,i.e someone must have changed the
material group from 02 to 04.
So in MARA table the value is showing as 04 and in RESB its showing as 04.
Once after creating reservation ,if such changes are made,as far as i know that
will not get updated or reflected in RESB.
Better confirm the same,in MM03 - Display mode of the material and after going
into any one of the view,in the top menu check Environment - Display Changes -
you may get one or a list of changes that were made,along with the user,date &
time details.
<b>If useful reward points</b>
Regards
Mangal -
Subject area security validating users and groups from external table
Hi all.
I don't have practice to put question here, but there is one problem, that seems don't work correctly in OBIEE.
I'm trying to put users in groups within external table and this works fine.
I put security on the subject area level like this:
SA1 -> GroupA allow, Everyone not allow
SA2 -> GroupB allow, Everyone not allow
External table:
User----------Group
A---------GroupA;GroupB
B---------GroupB
Users A, B and GroupA, GroupB exists in the RPD, but I didn't put users inside them, I want this from table.
From the init block, external table I'm taking users and join them in the group. Same name users and groups are also in the presentation service.
When i connect with user A i don't see any subject area, when go to My Account i see in Group Membership/GroupA and GroupB, so it's readed from the external table.
Why in this case the subject area permission is not working?
It works if I explicitly put users in groups, in the RPD.
I have read this blog entry http://kpipartners.blogspot.com/2009/07/groups-webgroups-and-delivers.html and it is said that this works, but I'm interested how.
What should we have in the presentation part, administration, Manage Privileges -> Access within Oracle BI Answers option for those two subject area?
This doesn't work or something is missing:
Re: Security on Subject Areas
Regards
Goran
http://108obiee.blogspot.comWhat should we have in the presentation part, administration, Manage Privileges -> Access within Oracle BI Answers option for those two subject area?Yes, you should remove Everyone and add the relevant groups to each Subject Area. You don't need to set privileges in the RPD, in fact that's probably why it doesn't work for you. Leave your RPD Presentation Catalog as "Everyone" = Read as you will controlling access from the Presentation Services and it should work.
-
Hi ..
How can I group an internal table instead of a similar field. For example I want to move internal table columns by same belnr's .Hi Yusuf
Am not sure if this is what you are looking for, but please try with offset.
Eg:
Considering an example whereby Int.Table IT_VBAK holds VBELN(Sales Document Numbers) & Int.Table IT_OBJNR holds the Status object numbers.
Fields in both internal tables might not match to group but field OBJNR has sales document numbers as a part.
In this case we can go as below:
LOOP AT it_objnr.
READ TABLE it_vbak WITH KEY vbeln = it_objnr-objnr(10). <--- First 10 chars of OBJNR is sales document number
ENDLOOP.
In the above example, field lengths are different, hence we use OFFSET operations to compare.
Considering another example, Plant is reffered as WERKS in few tables and as BWKEY in few tables in this case we can approach this way:
LOOP AT it_marc.
READ TABLE it_mbew WITH KEY matnr = it_marc-matnr
bwkey = it_marc-werks.
ENDLOOP.
Hope this is what you are looking for.
Do correct me if my understanding is wrong.
Kind Regards
Eswar -
How to combine 2 the same tables from 2 different databases
We have made 2 databases company1 and company2
Both databases contains the same tables
Now we want to make a report with server reporting services. The report must give us information from the 2 databases.
We use the following query:
SELECT '501'as divisie, GRV_DebtorOutstanding2.[Debtor code] AS Debiteur, GRV_DebtorOutstanding2.cmp_name AS Naam, SUM(GRV_DebtorOutstanding2.[Outstanding Amount]) AS Saldo,
GRV_DebtorOutstanding2.blokkade, GRV_Debtors.City
FROM [501].dbo.GRV_DebtorOutstanding2 INNER JOIN
[501].dbo.GRV_Debtors ON GRV_DebtorOutstanding2.[Debtor code] = GRV_Debtors.[Debtor code]
WHERE (GRV_DebtorOutstanding2.blokkade = 'B')
GROUP BY GRV_DebtorOutstanding2.[Debtor code], GRV_DebtorOutstanding2.cmp_name, GRV_DebtorOutstanding2.blokkade, GRV_Debtors.City
ORDER BY Debiteur
when we use the same query to select the data of the other database in the same query it doesn't work. I have tried it with the command Union All
But it crashes,
please help, to fix itHi Robert,
According to your description, you have created two same databases. When you run the same query for the second database, it doesn’t work.
In your scenario, since databases are the same and the query for first database can work fine, it should also work when query the second database using the same query. When you create second dataset, please check if you have used a correct datasource
which is second database. Then try to run the query again. If issue persists, please share the error message around the time when you query the second database.
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Combine 2 Queries (from SAME table) into a SINGLE query
I have this two queries (from SAME table), and want to combine into one SINGLE query, how?
How can we use CASE WHEN THEN for such situation?
Query1:
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min:' AS Productive_Time,
Floor(t_inner.OperatorDownTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.OperatorDownTime,3600) / 60),2,0) || 'min:' AS OperatorDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime,
sum(TIME_IDLE) AS OperatorDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE ) t_inner
Query 2:
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
see http://postimg.org/image/koq87iyyz/ and
http://postimg.org/image/fv3zxa38nwith the first query,
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min' AS Productive_Time
FROM
(SELECT SYSTEMTYPE,
--sum(TIME_TEST) AS TIME_TEST,
--sum(TIME_SYSTEM) AS TIME_SYSTEM,
--sum(TIME_STEP) AS TIME_STEP,
--sum(TIME_IDLE) AS TIME_IDLE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/koq87iyyz/
with the second query,
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/fv3zxa38n/
I want to come those 2 queries into a single query, such that it gives both outputs as above. Let me know if you need any other information. thanks. -
Comparing same tables from two schemas
I had already posted a similair thread on this . So, i thought i would start a new thread on this to avoid confusion
I want to generate a report which will show the difference in data type of columns from same tables in two different schemas.
The below query using MINUS shows the difference.
create table SCOTT.mytab1 (empid number);
create table HR.mytab1 (empid varchar2(34));
SELECT table_name, column_name, OWNER schema, data_type
FROM dba_tab_cols where owner = 'SCOTT'
AND TABLE_NAME = 'MYTAB1'
MINUS
SELECT table_name, column_name, OWNER schema, data_type
FROM dba_tab_cols where owner = 'HR'
AND TABLE_NAME = 'MYTAB1'
Result:
TABLE_NAME COLUMN_NAME SCHEMA DATA_TYPE
MYTAB1 EMPID SCOTT NUMBERBut , since it is a report, i want to show results form both schemas who has column of different data types with same table names
Expected output:
TABLE_NAME COLUMN_NAME SCHEMA DATA_TYPE
MYTAB1 EMPID SCOTT NUMBER
MYTAB1 EMPID HR VARCHAR2Anyway i could achieve this?Hello,
I can explain the analytical part, it is not so hard to understand (at least in this case).
I've created the tables with 2 columns : EMPID has different datatype, but NAME has the same datatype :
create table SCOTT.mytab1 (empid number, name varchar2(50));
create table HR.mytab1 (empid varchar2(34), name varchar2(50));Then I run only the subquery with the analytical part :
SELECT OWNER schema,table_name, column_name , data_type,
count(*) over (partition by table_name, column_name, data_type) c
FROM dba_tab_cols
where owner in ( 'SCOTT','HR')
AND TABLE_NAME = 'MYTAB1' ;
SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE C
SCOTT MYTAB1 EMPID NUMBER 1
HR MYTAB1 EMPID VARCHAR2 1
SCOTT MYTAB1 NAME VARCHAR2 2
HR MYTAB1 NAME VARCHAR2 2This query returns all columns for MYTAB1 in the 2 schemas. The analytical function count how many rows you have for each existing group of TABLE_NAME, COLUMN_NAME, DATA_TYPE, just like a normal count(*) with a GROUP BY, but it does not change the number of rows of the result (unlike the GROUP BY function).
As you can see in the result above, when you have columns with different datatype, the group appears once, so C=1. When the datatype is the same, the group appears twice, so C=2.
So I have put a filter on C=1 :
SELECT * FROM (
SELECT table_name, column_name, OWNER schema, data_type,
count(*) over (partition by table_name, column_name, data_type) c
FROM dba_tab_cols
where owner in ( 'SCOTT','HR')
AND TABLE_NAME = 'MYTAB1'
) WHERE c=1;
TABLE_NAME COLUMN_NAME SCHEMA DATA_TYPE C
MYTAB1 EMPID SCOTT NUMBER 1
MYTAB1 EMPID HR VARCHAR2 1You can do many things with analytical functions, but for beginning with them, you can use them when you need something with a GROUP BY, but you want to keep all rows in the result. You just have to put in the PARTITION BY clause the columns you would have used in the GROUP BY clause.
I hope I am clear, but if not, do not hesitate to ask for more information.
Regards,
Sylvie -
Calculating average time from two records from the same table.
Hi all
I need to calculate the average time between two events that are recorded in the same table.
The table is TMS_MESSAGE_AUDIT_LOG
MESSAGE_ID VARCHAR2(16 BYTE) NOT NULL,
MESSAGE_VERSION NUMBER(2) NOT NULL,
CREATE_TM VARCHAR2(18 BYTE) NOT NULL,
MESSAGE_STATUS VARCHAR2(30 BYTE),
TRANSACTION_TYPE_NM VARCHAR2(30 BYTE),
MESSAGE_TP VARCHAR2(3 BYTE),
WORKFLOW_OBJECT VARCHAR2(30 BYTE) NOT NULL,
WORKFLOW_REQUEST VARCHAR2(30 BYTE) NOT NULL,
WORKFLOW_RETURN_CD VARCHAR2(30 BYTE) NOT NULL,
AUDIT_ACTION VARCHAR2(255 BYTE),
LAST_UPDATE_USER_LOGON_ID VARCHAR2(12 BYTE),
LOCAL_TM VARCHAR2(18 BYTE) NOT NULL,
LOCAL_TIME_ZN_NM VARCHAR2(70 BYTE) NOT NULL,
LOCAL_DAYLIGHT_IN CHAR(1 BYTE) NOT NULL,
FPRINT VARCHAR2(30 BYTE)
What i now need is
When the MESSAGE_ID is the same i need have the average time between when the MESSAGE_STATUS is AA and BB ( I need the time out of the CREATE_TM field )
And this for every 15 minutes interval.
Because this table will become BIG millions and millions of records it needs to be fast.
Can anybody help me.
MarcelSomething like this?
CREATE TABLE wr_test
( message_id VARCHAR2(16 BYTE) NOT NULL
, message_version NUMBER(2) NOT NULL -- Assumption: Acknowledged ver > Received ver
, create_tm VARCHAR2(18 BYTE) NOT NULL
, message_status VARCHAR2(30 BYTE)
, transaction_type_nm VARCHAR2(30 BYTE)
, workflow_object VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, workflow_request VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, workflow_return_cd VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, audit_action VARCHAR2(255 BYTE)
, last_update_user_logon_id VARCHAR2(12 BYTE)
, local_tm VARCHAR2(18 BYTE) NOT NULL
, local_time_zn_nm VARCHAR2(70 BYTE) DEFAULT 'GMT' NOT NULL
, local_daylight_in CHAR(1 BYTE) DEFAULT 'x' NOT NULL );
INSERT ALL
INTO wr_test
( message_id
, message_version
, create_tm
, message_status
, local_tm )
VALUES ( message_id
, 1
, create_tm
, '(Receive)'
, TO_CHAR(local_tm,'YYYYMMDD HH24:MI:SS') )
INTO wr_test
( message_id
, message_version
, create_tm
, message_status
, local_tm )
VALUES ( message_id
, 2
, create_tm
, 'Wait CLSB Ack'
, TO_CHAR
( local_tm + NUMTODSINTERVAL(DBMS_RANDOM.VALUE(0,2e5),'SECOND')
, 'YYYYMMDD HH24:MI:SS' ) )
SELECT ROWNUM AS message_id
, TO_CHAR(SYSDATE,'YYYYMMDD HH24:MI:SS') AS create_tm
, DATE '2000-01-01' + DBMS_RANDOM.VALUE(0,3) AS local_tm
FROM dual CONNECT BY ROWNUM < 100000;
WITH src AS
( SELECT message_id
, message_status
, message_version
, TO_DATE(SUBSTR(local_tm,1,17),'YYYYMMDD HH24:MI:SS') AS dt
, TO_DATE(SUBSTR(local_tm,1,8),'YYYYMMDD') AS dt_day
, TO_CHAR(TO_DATE(SUBSTR(local_tm,10,8),'HH24:MI:SS'),'SSSSS') AS dt_sec
FROM wr_test
WHERE message_status IN ('(Receive)','Wait CLSB Ack') )
SELECT dt_day + NUMTODSINTERVAL(period,'SECOND') AS dt
, NUMTODSINTERVAL(AVG(elapsed),'DAY') AS avg_elapsed
, NUMTODSINTERVAL(MIN(elapsed),'DAY') AS min_elapsed
, NUMTODSINTERVAL(MAX(elapsed),'DAY') AS max_elapsed
, COUNT(*)
FROM ( SELECT message_id
, message_status
, dt_day
, TRUNC(dt_sec/300)*300 AS period
, LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) AS ack_dt
, LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) - dt AS elapsed
FROM src ) cal
WHERE cal.message_status = '(Receive)'
GROUP BY dt_day, period
ORDER BY 1;Replace "wr_test" with "tms_message_audit_log" in the WITH subquery to test on your data. -
How to populate data in the same table based on different links/buttons
Hi
I'm using jdeveloper 11.1.4. I have a use case in which i need to populate data in the same table based on click of different links.
Can anyone please suggest how can this be achieved.
ThanksI have a use case in which i need to populate data in the same table based on click of different linksDo you mean that you need to edit existing rows ?
What format do you have the date in - table / form ?
Maybe you are looking for
-
Problem with application.xml
Hi, I would be really grateful if anybody could help me on this. My application.xml is given below: <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> <application> <d
-
APEX 4.2 bug with mobile page submit action
Hi, I am using the APEX 4.2 mobile theme which has a "Select List" page item and where the "Page Action when Value Changed" is set to "Submit Page". The submit works when the values are in pull down but when the values come from popup window then it
-
Hello Guru's, Request for information on smart documentation on the integration between Trade Promotion Management and SCM-Demand Planning from an architecture perspective how to configure for the give senario where we from APO demand planning, we pr
-
Hey all, Since I upgraded from Snow Leopard to Lion my Safari (5.1) feels chunky after a while of use. Scrolling starts to stutter a bit, opening new tabs takes longer and so on.. So I descided to check the browser activity and I see Safari uses 405M
-
Error- PPDS Planning board -Heuristic 'Adjust and Reschedule Block Limits'
Hi, I have created a sales order in ERP and overload (within tolerance) a block of a block planning enbaled resource in APO. The block is overloaded. Then I've run the "Heuristic 'Adjust and Reschedule Block Limits'" under Functions-->Heuristics. Now