Query for Finding the Daily Cumulative Production Total
Hi Experts,
I want Query based Report for finding Daily Cumulative i.e Running Production Total
Suppose Yesterdays Production for Item A0001 is 20 and Todays Prodction is 20 then it will show 50 but it shout be datewise selection.
Warm Regards,
Sandip Kokate
Hello
Report Scenario as follow
Item Code Item name Todays Producion Yesterdays Production Total Productio
A001 Computer 20 20 40
A002 Mouse 10 05 15
A003 CPU 15 05 20
This is Exact Report
Regards,
Sandip Kokate
Similar Messages
-
Query for Finding the Date History
Hi Geeks,
My Table looks like this
Employee Assignment Position Job Grade Start_date End_date
101 132 2055 Clerk C01 10-Mar-00 11-Feb-01
101 132 2055 Clerk C02 12-Feb-01 15-Dec-01
101 132 2056 Clerk C02 16-Dec-01 22-Jul-03
101 132 2055 Clerk C03 23-Jul-03 31-Dec-4000 --(unassigned)
Now I need output like
Employee Assignment Position Start_date End_date
101 132 2055 10-Mar-2000 15-Dec-2001
101 132 2056 16-Dec-2001 22-Jul-2003
101 132 2055 23-Jul-2003 31-Dec-4000 --(unassigned)
The following important things are to be considered
1. Rows to be grouped by position
2. Each row much have the start date and end date of the employee position. If the employee is the same postion and different grade or job that doesnt matter. But if the employee jumps from his position (2055) to 2056 and after sometime he comes to the same position (i.e. 2055) the date history should be separate.
I am unable to derive the logic also. I think we need to create a function for this.
Kindly help me out.
Thanks in Advance
Punithavel
Message was edited by:
Punithavel
Message was edited by:
PunithavelToo difficult to read. I have no database access to test (usually I use a step by step approach, proceeding with the next step when the current one is OK).
I can describe a general idea (may post something afterwards with no promise it will work)
step 1: mark the position changes
step 2: retain only mark 1 and mark max(mark) of each group
step 3: make a single row from the two rows of each group
Regards
Etbin
with
marking as
(select employee,assignment,position,start_date,end_date,
row_number() over (partition by employee,assignment,position order by start_date) the_mark
from the_table
collecting as
(select employee,assignment,position,start_date,end_date,the_mark
from marking m
where the_mark = 1
or the_mark = (select max(the_mark)
from marking
where employee = m.employee
and assignment = m.assignment
and position = m.position
group by employee,assignment,position
having count(*) > 1
combining as
(select employee,assignment,position,
case when the_mark = 1 then start_date end start_date,
case when the_mark = 1
then case when lead(position,1) over (partition by employee,assignment,position order by start_date) = position
then lead(end_date,1) over (partition by employee,assignment,position order by start_date)
else end_date
end
end end_date
from collecting
select employee,assignment,position,start_date,end_date
from combining
where start_date is not null
order by employee,assignment,position,start_date*** not tested ***
Message was edited by: Etbin
user596003
on a lazy afternoon I took a look at your friend's solution too and I like it.
It's more concise than mine (defining starts and ends).
Not being able to test it the only problem in his solution might be the absence of order by clauses to assign correct rownums
WITH lag_and_lead AS
(SELECT employee,assignment,position,start_date,end_date,
LAG (position) OVER (PARTITION BY employee,assignment ORDER BY start_date) AS lag_position,
LEAD (position) OVER (PARTITION BY employee,assignment ORDER BY start_date) AS lead_position
FROM your_table
ORDER BY employee,assignment,start_date
starts AS
(SELECT employee,assignment,position,start_date,ROWNUM rn
FROM lag_and_lead
WHERE position <> lag_position
OR lag_position IS NULL
order by employee,assignment,start_date
ends AS
(SELECT employee,assignment,position,end_date,ROWNUM rn
FROM lag_and_lead
WHERE position <> lead_position
OR lead_position IS NULL
order by employee,assignment,start_date
SELECT starts.employee,starts.assignment,starts.position,starts.start_date,ends.end_date
FROM starts,ends
WHERE starts.employee = ends.employee
AND starts.assignment = ends.assignment
AND starts.position = ends.position
AND starts.rn = ends.rn
EMPLOYEE ASSIGNMENT POSITION JOB GRADE START_DATE END_DATE
101 132 2055 Clerk C01 10-Mar-2000 11-Feb-2001
101 132 2055 Clerk C02 12-Feb-2001 15-Dec-2001
101 132 2056 Clerk C02 16-Dec-2001 22-Jul-2003
101 132 2055 Clerk C03 23-Jul-2003 31-Dec-4000
lag_and_lead
EMPLOYEE ASSIGNMENT POSITION START_DATE END_DATE lag_position lead_position
101 132 2055 10-Mar-2000 11-Feb-2001 null 2055
101 132 2055 12-Feb-2001 15-Dec-2001 2055 2056
101 132 2056 16-Dec-2001 22-Jul-2003 2055 2055
101 132 2055 23-Jul-2003 31-Dec-4000 2056 null
starts
EMPLOYEE ASSIGNMENT POSITION START_DATE rn
101 132 2055 10-Mar-2000 1
101 132 2056 16-Dec-2001 2
101 132 2055 23-Jul-2003 3
ends
EMPLOYEE ASSIGNMENT POSITION END_DATE rn
101 132 2055 15-Dec-2001 1
101 132 2056 22-Jul-2003 2
101 132 2055 31-Dec-4000 3
EMPLOYEE ASSIGNMENT POSITION START_DATE END_DATE
101 132 2055 10-Mar-2000 15-Dec-2001
101 132 2056 16-Dec-2001 22-Jul-2003
101 132 2055 23-Jul-2003 31-Dec-4000Regards
Etbin
Message was edited by: Etbin
user596003 -
Write a query for finding STDDEV for OLAP Cube
Can anybody post a sample query which will find the standard deviation of sales for each month in the sample GLOBAL OLAP schema for Oracle 11g.
The OLAP option automatically generates a set of relational views on cubes, dimensions, and hierarchies in Oracle 11g. So how can i write a query for finding the Standard deviation on these views.The easiest way to do this is to do this directly within the AW using a custom calculated measure. In AWM11g you can use the 11g custom measure wrapper to execute the STDDEV function:
olap_dml_expression('function',data type)
For example
olap_dml_expression('STDDEV(cube_name, time_dimension_name)',number)
You can then simply expose this calculated measure as another column in your SQL View and then there is no need to use the SQL equivalent. This means the calculation is performed inside the AW (which is as close to the source data as you can get) ensuring performance of the whole query remains high.
If necessary you can take this a step further, if required, and wrap the STDDEV calculation within an OLAP DML program that would allow you to manipulate the status of time within the calculation. For example, you may want the STDDEV calc to only take into account the last 12 time periods rather than all time periods currently in status.
Hope this helps
Keith Laker
Oracle EMEA Consulting
OLAP Blog: http://oracleOLAP.blogspot.com/
OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
DM Blog: http://oracledmt.blogspot.com/
OWB Blog : http://blogs.oracle.com/warehousebuilder/
OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html -
Query to find the latest record with respect to the current status
Dear gurus
I have the following data in a table
Customernum
bkcode
reqtdate
Prevstat
currstat
The data will be like this
CustomerNum bkcode reqdate prevstat currstat
5900 1 03-Aug-12 0 1
5900 1 06-Aug-12 1 0
5900 5 22-Jun-12 0 1
If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
I have trying hard to get this thing confused what to use Lead or Max
Kindly guide meHi,
one way here:
WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
AS
SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
FROM (SELECT a.*
, ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
ORDER BY reqdate DESC) AS rn
FROM mytable a
WHERE rn=1
AND currstat=1;
CUSTOMERNUM BKCODE REQDATE PREVSTAT CURRSTAT
5900 5 22-JUN-12 0 1Regards.
Al
Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
Changed again!! Previous logic was wrong -
Query For Finding Yearly Opening and Closing Balance for All the Items
Hi Experts,
I am working on Query Based Report for finding the Yearly Opening and Closing Stock for all the Items
i will give yearwise selection and I want opening and closing stock in between that years
Warm Regards,
Sandip Kokate
Edited by: Sandipk on May 20, 2011 1:58 PMHi,
Declare @SDate DateTime
Declare @EDate DateTime
Declare @Whse nvarchar(10)
Set @SDate= (SELECT min(F_RefDate) FROM OFPR T1 where T1.[Name] ='[1%]' )
Set @EDate= (SELECT max(T_RefDate) FROM OFPR T1 where T1.[Name] ='[%1]' )
Set @Whse=(Select Max(s2.Warehouse) from OINM S2 Where S2.Warehouse = '[%2]')
BEGIN
Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,
sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,
(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM
from( Select N1.Warehouse, N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
as OpeningBalance, 0 as INq, 0 as OUT From dbo.OINM N1
Where N1.DocDate < @SDate and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,
N1.Dscription Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance,
sum(N1.inqty) , 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <= @EDate
and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription
Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT
From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <=@EDate and N1.OutQty > 0
and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription) a, dbo.OITM I1
where a.ItemCode=I1.ItemCode
Group By a.Itemcode Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0 Order By a.Itemcode
END
I hope this will work for you.
In above query you can also user OFPR.Code, OFPR, Category OFPR.Indicator instead of OFPR.Name.
Regards
Vaibhav Anharwadkar
Edited by: Vaibhav Ancharwadkar on May 24, 2011 9:23 AM -
Sql query to find the balances for a customer account wise.
Hi,
Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
presently we are using this query, but the output doesnot return the expected result.
SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
FROM ra_cust_trx_line_gl_dist_all gld,
gl_code_combinations c,
ar_payment_schedules_all ps,
RA_CUSTOMER_TRX_ALL rat,
ra_customers rc
WHERE c.CHART_OF_ACCOUNTS_ID = 101
and gld.code_combination_id = c.code_combination_id
and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
and ps.customer_id=rc.customer_id
and ps.status='OP'
and ps.gl_date <= :PDATE
and ps.org_id=:PORGID
and ps.class in ('GUAR','INV','DM','DEP')
and c.SEGMENT4=:Account_id
and ps.customer_id=:Customer_id
Thanks in advance.
Kalyan.Can someone help us with this.
-
Query to find the the free space in raw disks
I am new to ASM.
What is the query to find the free space in the raw disks in ASM diskgroup.? Can i get space info about individual raw disks in the disk group?
Is there an ip address for the ASM disk group? If so how can i find it?below query will give you total and free space for each raw disk from a disk group.
select dg.name, d.name, d.total_mb, d.free_mb from v$asm_disk d, v$asm_diskgroup dg where dg.group_number=d.group_number order by 1;
There no IP address attached to ASM disk group. Why do you want associate IP address with a Disk group? -
Query to find the list of users having access to a particular scenario
Hi,
I am learning Hyperion Planning 9.2 x version. I wanted to know the query to find the list of users having access to Plan Iteration - 1 scenarion.
As I am new to Hyperion Essbase and Hyperion Planning, I am assuming these ideas work out to get the desired result.
1) As Hyperion Planning uses Relational DB to store the User Security information, we can query the list of users who is having access to Plan Iteration - 1 Scenario.
I am not sure if this solution works. Please correct me If I am wrong.
2) We can also query from the essbase editor to find out who all having access to this scenario.
If the above is correct, can you please provide me the query.
I am really need of this and I will be happy if any one provide the solution.
Thanks & Regards,
Upendra. BesthaHi,
If you are looking for some SQL to retrieve the access rights by member then you can use something like (SQL Server code though can easily be modified for Oracle)
SELECT usr.object_name as Username,mem.object_name as Member,
'Access Rights' = CASE acc.access_mode
WHEN -1 THEN 'None'
WHEN 1 THEN 'Read'
WHEN 2 THEN 'Write'
WHEN 3 THEN 'Write'
ELSE 'Unknown' END,
'Relation' = CASE acc.flags
WHEN 0 THEN 'Member'
WHEN 5 THEN 'Children'
WHEN 6 THEN 'Children (inclusive)'
WHEN 8 THEN 'Descendants'
WHEN 9 THEN 'Descendants (inclusive)'
ELSE 'Unknown' END
FROM
hsp_access_control acc, hsp_object mem, hsp_object usr
WHERE acc.object_id = mem.object_id
AND acc.user_id = usr.object_id
AND mem.object_name = 'Plan Iteration - 1'
Cheers
John
http://john-goodwin.blogspot.com/ -
Query to find the no of columns in a table
Is there a query to find the total number of columns in a table?
Dou you know read?
-- the number of rows in a table named yourtable:
select count(1) from yourtable;
-- the number of columns in a table
-- If is a user's table:
select count(1)
from user_tab_columns
where table_name='YOURTABLE'
--If it is´t
select count(1)
from DBA_tab_columns
where owner = 'USEROWNER'
and table_name='YOURTABLE' -
Query to find the Salary table details HRMS 11i
I am looking query to find the persons salary details in Oralce EBS 11i.
I tried the below query bu it didn'ty work.
SELECT papf.employee_number
,papf.full_name
,pj.NAME job
,haou.NAME ORGANIZATION
,ppp.proposed_salary_n salary
FROM per_all_people_f papf
,per_all_assignments_f paaf
,per_jobs pj
,hr_all_organization_units haou
,per_position_definitions ppd
,per_all_positions pap
,per_pay_proposals ppp
WHERE 1 = 1
AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
AND papf.current_employee_flag = 'Y'
AND papf.employee_number IS NOT NULL
AND paaf.person_id = papf.person_id
AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND paaf.job_id = pj.job_id
AND paaf.organization_id = haou.organization_id
AND paaf.position_id = pap.position_id
AND pap.position_definition_id = ppd.position_definition_id
AND ppp.pay_proposal_id = (SELECT MAX (pay_proposal_id)
FROM per_pay_proposals
WHERE assignment_id = paaf.assignment_id)
In our case all the below tables have 0 records..
select count(*) from PER_PAY_PROPOSALS ;
COUNT(*)
0
select count(*) from pay_element_entry_values_f;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRY_VALUES_F;
COUNT(*)
0
select count(*) from PAY_ELEMENT_ENTRIES_F;
COUNT(*)
0Hi,
Your results clearly states that there is no salary data which is been captured as well as there are no element entries which are assigned to any assignment.
Please do the below which will insert records in salary as well as element entries table:
1. Add a salary proposal to any active employee (People Enter and Maination --> Search for any employee --> Assignment --> Salary) - This will insert a record in PER_PAY_PROPOSALS table
2. Add an element entry to any active assignment (People Enter and Maination --> Search for any employee --> Assignment --> Entries) - This will insert a record in PAY_ELEMENT_ENTRIES_F and PAY_ELEMENT_ENTRY_VALUES_F table
Hope this clarifies.
Thanks,
Sanjay -
Can anybody provide the SQL query to find the files uploaded in a particular folder?
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
NevinNevin,
Be great if we could know the version of Portal. For Rel. 1, here's the query
select id,masterthingid from wwv_things
where siteid = &site
and cornerid = &corner
&site - Content Area id
&corner - Folder id
if you don't know the folder id, use
select id from wwv_corners where siteid = &site
and name = &folder
Hope this helps. I have run into this situation before. Usually, the culprits were
one of the following:
1. Junk Characters in description of item (caused due to Copy-Paste)
2. Special Characters in the File name
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
Nevin -
SQL Query to find the Notify upon Completion employees
Hi,
I am looking for a query to find the names of the employees/users who are notified upon the completion of the Concurrent Programs. I know how to find the concurrent program details but not able to find notify upon completion employees details. Please help me.
Thanks,
KMThanks Scott for responding. There is no any custom code. Here is the navigation to reach there:
System Administrator -> Requests -> View -> Specific Requests -> Open any request ->View Details -> Options -> Notify the following people
I am looking for the query to find these notified people using SQL Query.Query FND_CONCURRENT_REQUESTS table (NOTIFY_ON_PP_ERROR column) -- http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE
Thanks,
Hussein -
Query to find the list of BP without having Particular GL transactions.
Hi Experts,
I want the query to find the List of Business partner who is not having Journal entry for Certain General ledger.
Scenario: we are creating JE for TDS posting.
so, i want to know the list of BP , who and all not having particular TDS GL for the particular period.
Thanks in advance,
DwarakHi Dwarak,
Sure, no problem
DECLARE @AcctCode AS NVARCHAR(100)
SELECT @AcctCode=T0.AcctCode FROM OACT T0 WHERE T0.AcctCode='[%0]'
DECLARE @DateFrom AS DATETIME
SELECT @DateFrom=T1.RefDate FROM JDT1 T1 WHERE T1.RefDate=[%1]
DECLARE @DateTo AS DATETIME
SELECT @DateTo=T2.RefDate FROM JDT1 T2 WHERE T2.RefDate=[%2]
SELECT CardCode FROM OCRD WHERE CardType='S'
AND CardCode NOT IN(
SELECT DISTINCT ContraAct FROM JDT1
WHERE Account=@AcctCode AND RefDate BETWEEN @DateFrom AND @DateTo)
Ok, now, here's the problem that I just encountered. This query will work, but, no matter how we fill the parameter, it will show you the very same result. To be honest, I don't know what's wrong with this query.
If you change all the variables ( @AcctCode and @DateFrom and @DateTo ) directly, it will give you the accurate result. Take this as an example:
SELECT CardCode FROM OCRD WHERE CardType='S'
AND CardCode NOT IN(
SELECT DISTINCT ContraAct FROM JDT1
WHERE Account='10030201' AND RefDate BETWEEN '2011-09-01' AND '2011-09-20')
I hard-code the account code, date from and date to for selection. System will show you the accurate result, but using parameter as in first query, system show same result no matter how we fill the parameter.
Sorry, it seems that I could only partially solved your problem here. I already tried to create a stored procedure and executing the stored procedure with parameter, but still, somehow SBO show very same result no matter if we change the parameter.
So, my solution need user to manually change the parameter in query. I know, this is a stupid solution, I'm afraid I can't help you to achieve perfect solution here. Maybe anyone here in the forum could guide me to fix my mistake in first query and how to rectify it?
Best Regards,
Hendry Wijaya -
Query to find the size of trigger?
query to find the size of trigger?
Can you define what the size of a trigger would be?
I suppose one measure might be to get the DDL for the trigger (DBMS_METADATA.GET_DDL) and do a DBMS_LOB.GetLength on the CLOB that is returned. I'm hard-pressed to find that a meaningful number, but it is a measure of "size".
Justin -
Query to find the Base tables of views
Hi,
Can you pl let me know the query to find the base tables on which the view is based.I looked into views like ci_view_definitions but i could not find them.
Thanks for your help
thanx,
Suji.select vw.name viewname, nvl( tabdef.name, vwdef.name) "based on"
from ci_view_definitions vw
, i$sdd_vwtab
, ci_view_definitions vwdef
, ci_table_definitions tabdef
where view_ref = vw.id
and table_ref = tabdef.id (+)
and table_ref = vwdef.id (+)
Maybe you are looking for
-
Vertical allignment of columns in tabular format of report in obiee 10g
Hi, I have a client requirement in which the colums are to be alligned vertically instead of being displayed horizontallty which is the default format in obiee. Can anyone help me in achieving this requirement . below goes the format of report we nee
-
I received an email from Adobe requiring me to reset my Adobe password due to security breaches on 10/11/13. I determined it was a genuine request. I reset my password, then signed in on Adobe with the new password. From that point on, I have only te
-
Update mass period validity in Pricelist condition
Hello, I have a huge number of pricelist conditions with missing validity dates (valid from and valid to). I like to mass update these datas so I made a recording of VK12 (through SHDB). Unfortunately even if in foreground process everything seems OK
-
Multifunction Printers - Please reply with your opinons
My wife and I are looking to buy a Brother MFC-820CW. Does anyone have one of these? If so, what's your opinion of it? Can it in fact print to fax, and receive a fax straight to a computer with out printing it and then scanning it? Also, can the scan
-
Dynamically linked text and some...
OK so I'm obviously not looking for someone to code this but I'm hoping for some "been there done that" type input. I have a set of InDesign files that for simplicities sake I'll care novel and another set that is derivative. Now I would like to be a