SQL query using analytical/report problem
HelloI'm having some problem writing of my request. I have this table below:
create table t (priority number,
plannedamount number,
availablepieces number,
material_id varchar2(20))
/
insert into t values (1, 15, 30, 'A');
insert into t values (2, 20, 30, 'A');
insert into t values (3, 5, 30, 'A');
insert into t values (4, 8, 30, 'A');
insert into t values (5, 4, 30, 'A');
insert into t values (1, 2, 10, 'B');
PRIORITY | AMOUNT PLANNED | PARTS AVAILABLE | MATERIAL_ID-------------------------------------------------------------------
1 15 30
2 20 30
3-5-30
4-8-30
5 4 30
1 2 30.
Each line is a command of customer order a material. I am grouping by material and her ordering of priority. I want to display a new column called reserved not pieces yet. This column that indicates whether the order can be fully booked for this order current classification by priority.
If the line can be reserved it subtracts the will and bring it to the next line. If it is not non-reserved pieces will remain the same.
I tried to use sum(), first(), lag(), lead(), etc., but I still can't get the correct result.
PRIORITY | AMOUNT PLANNED | PARTS NOT YET RESERVED. MATERIAL_ID
-------------------------------------------------------------------
1 15 30
2 20 15
3-5-15
4-8-10
5-4-2
1 2 30
Anyone can develop or advice on which method to use to create this column?
Thank you. .
Published by: 998373 on April 5, 2013 11:42
Published by: 998373 on April 5, 2013 11:43
may be like this if you are on 11 GR 2, using recursive subquery
with t(PRIORITY, PLANNED_AMOUNT,AVAILABLE_PIECES , MATERIAL_ID) as
(
select 1, 15, 30, 'A' from dual union all
select 2, 20, 30, 'A' from dual union all
select 3, 5, 30, 'A' from dual union all
select 4, 8, 30, 'A' from dual union all
select 5, 4, 30, 'A' from dual union all
select 1, 2, 30, 'B' from dual
),
rec(PRIORITY, PLANNED_AMOUNT,AVAILABLE_PIECES , MATERIAL_ID, PIECES_LEFT)as
(
select PRIORITY, PLANNED_AMOUNT, AVAILABLE_PIECES, MATERIAL_ID, case when AVAILABLE_PIECES >= PLANNED_AMOUNT Then AVAILABLE_PIECES- PLANNED_AMOUNT ELSE AVAILABLE_PIECES END
from t where PRIORITY=1
union all
select t.PRIORITY, t.PLANNED_AMOUNT, t.AVAILABLE_PIECES, t.MATERIAL_ID , case when r.PIECES_LEFT >= t.PLANNED_AMOUNT Then r.PIECES_LEFT- t.PLANNED_AMOUNT ELSE r.PIECES_LEFT END
from rec r, t
where r.PRIORITY+1=t.PRIORITY and r.MATERIAL_ID=t.MATERIAL_ID
)
select * from rec
Tags: Database
Similar Questions
-
DA on updatable report items Sql query using the class
Request Express 4.2.5.00.08
10-11 g Oracle
I have a page, so it has a link/button when he clicks then modal region will appear. Modal region has a as a table (Type SQL Query (updateable report)). All work very well so far.
However, I've now added some complex things.
for example. My region is based on the query of SQL Type (editable report).
SELECT id, name of family, Traghetti, area, d_date, start_time, End_time, displacement, role of table where id =: P10_ID;
I can also add a new line of course.
My problem is, (point) Shift display based on the value of Start_Time point) and so I made sure the class for two items.
for example, Start_Time (' class = "st_tm" ') and Maj ('class to = "Shift_time" '). Start_Time is based on (LOV) and shift is off the point in the sql query, but change the Start_Time.
And now, I created the DA.
1. event: change
Selection type: jQuery Selector
jQuery Selector: .st_tm
Condition: No.
1. action: set value
Set type: Expression Javascript
The JavaScript Expression: $(this.triggeringElement) .val ();
The element affected: P10_X1 (it is a hidden item)
2. action: Plsql Code
Code: start to null; end;
Page items to submit: P10_X1
3. action: Plsql Code
Code: start
If: P10_X1 between '03' AND '11' then
: P10_X1: = 'EARLIES ';
elsif: P10_X1 then '12' and '18'
: P10_X1: = 'LATES ';
on the other
: P10_X1: = 'NIGHTS';
end if;
end;
Page items to submit: P10_X1
NOW another DA
Event: change
Article (s) P10_X1
Condition (in list)
value (HASTY, LATES, NIGHTS)
Action:
Set type: Expression Javascript
The JavaScript Expression: $(this.triggeringElement) .val ();
Affected item:
Selection type: jQuery Selector
jQuery Selector:. Shift_time
Well, I look forward all the above work well, but I'm having a problem.
If I have more than 1 lines on a modal region and if I change the Start_Time value for a row then MAJ (point) is changing but he effect on all lines.
I want, if I make the changes on the line line # 2 while only 2 # MAJ (point) must be not performed any other lines?
Help, please!
Kind regards
RI
I found the solution me thank you.
I removed all the DA mentioned above and created a new.
1. event: change
Selection type: jQuery Selector
jQuery Selector: .st_tm
Condition: No.
Scope of the event: dynamic and light on page load.
Action (Javascript code)
ROW_ID = $(this.triggeringElement).attr('id').substr (4);
If ($(this.triggeringElement). val() > = 03 &. val() $(this.triggeringElement))<= 11)="">=>
.Val ('EARLIES') $(«#f11_» + row_id);
}
ElseIf ($(this.triggeringElement). > 11 val() & $(this.triggeringElement). val())<= 18)="">=>
.Val ('LATES') $(«#f11_» + row_id);
}
ElseIf (. val() > $19 (this.triggeringElement)) {}
.Val ('NIGHTS') $(«#f11_» + row_id);
}
also created another DA because I have a disabled report items.
Event: before the page is sent.
$('_:_disabled').removeAttr ("disabled");
and finally created manual process of DML for tabular and everything works fine. (Insert, Update, and delete).
Kind regards.
-
Access APEX_APPLICATION. G_F01 in a SQL query for a report
APEX 4.0.2.00.07
I have a standard report with check boxes. The SQL along the lines of:
Then I have another report below, I want to drive based on the items checked in the first report. I know that the values of the checkbox in the APEX_APPLICATION. Collection of G_F01. Normally, these are accessible using pl/sql such as:SELECT APEX_ITEM.CHECKBOX(1,empno,'CHECKED') " ", ename, job FROM emp
But is it possible that I can access the collection from the sql for my second report.FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP DELETE FROM emp WHERE empno = to_number(APEX_APPLICATION.G_F01(i)); END LOOP;
that is, I want my sql to be something like:
I was hoping that the collection box would be available in the APEX_COLLECTIONS view, but it doesn't seem to be there.SELECT empno, day_of_service FROM emp_timesheet WHERE emp_no in <get access to the collection here>
Thank you
JohnJohn,
If the goal is to keep the values checked for another treatment then you could add them to a collection yourself.
create a process on your page that looks like this:
This will create your collection if not exist or don't delete everything currently in it if it exists and then insert your new selections.DECLARE l_col_name varchar2(30) := 'EMP_SELECTED'; BEGIN apex_collection.create_or_truncate_collection(l_col_name); FOR I in 1..APEX_APPLICATION.G_F01.COUNT LOOP apex_collection.add_member( l_col_name, to_number(APEX_APPLICATION.G_F01(i)) ); END LOOP; END;
your second question might look like this:
SELECT empno, day_of_service FROM emp_timesheet WHERE empno in (select C001 empno from apex_collections ac where ac.collection_name = 'EMP_SELECTED')
Edit
Some people choose to create a view of some collection queries ontop that will be repeated throughout the application so we can justcreate view selected_emps as select C001 empno from apex_collections ac where ac.collection_name = 'EMP_SELECTED'
and your new query will look like:
SELECT empno, day_of_service FROM emp_timesheet WHERE empno in (select empno from selected_emps)
See you soon,.
Janet Tyson
Published by: Tyson Janet on April 6, 2011 10:37
-
Find the sql query in statspack report
Salvation;
I have 11.5.10.2 and db version 9iR2... I took a statspack report, and I should find a sql query... But admin, is kill session and I can't see complite sorted SQL query by gets for DB...
so the question is find this query which is kiiled by admin?
Thank youHello
Its bad news to can not find this sql... So normally it istn killed by admin, I could find it from stats$ sql_summary or v$ sql_text?
It is possible.
Note: 153507.1 - Applications Oracle StatsPack
https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=153507.1And another question... If I have a sql printing is eating my cpu or my server resource, how do I find this sql? Under what title I can find in the statspack report
Refer to:
Note: 232443.1 - how to identify the resource intensive SQL for Tuning
https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=232443.1Kind regards
Hussein -
Can a report prepared with the free hand SQL(Sql Query) using a DB link
Hi all
To be developed a report based on query in OBIEE dashboards
Select the query - 1
UNION
Select the request - 2
First select source of the schema of a database and second query came from the other.
Is it possible to develop the report using the free hand THAT SQL based on a link to DB?
Y at - it feature to use the database link (link DB)?
I thank in advance
SMAWhat you ask, it's the live database query capabilities:
http://gerardnico.com/wiki/dat/OBIEE/presentation_service/obiee_direct_database_requestBut you can also use the repository's federated query capabilities to model a star schema with two star of two different sources of data schema.
See you soon
Nico -
Tabular of Autocomplete Ajax does not work in SQL query using apex_item.text.
Hello
Is it possible to use the search function that is used in, Dennis Kubicek example, section tabular ENAME of Autocomplete Ajax
in a query sql using apex_items?
Request line:
apex_item.text (17, xp.part_nr, null, null,'onfocus = "f_register (this);) 'autocomplete 'off' = ') PART '.
In a first time, I followed the example by adding «onfocus = "f_register (this);"autocomplete = "off" in the attributes of the element in the report field.»
It did not work... so tried to add computers in the attirbutes of the apex_item parameter.
But it still doesn't work. No errors are given, it does not.
Could someone help me please?
THX!
AstridOf course, it is. I just tested it in this example:
http://HTMLDB.Oracle.com/pls/OTN/f?p=31517:178
with an element created using apex_item package and it works.
If you have access to my Idée, you look at the source.
Denes Kubicek
------------------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------------------ -
SQL query for the report?
Hi all
I have a large table with column:
the code, street, data_type, credit, debt, saldo, date
I created query as
sum (saldo), code of Select tableA where data_types = 1 and date < ' 201010 "group by code
but cannot develop this request to be in the report as
COLUMN1 COLUMN2 COLUMN3 COLUMN4
Sum (saldo) - where type = 1 and date = '201201', sum (saldo) where type = 2, sum (saldo) If date = '201205', code
What is the best solution for sums of report for diferent data_types on a single line with just one code per lines?
concerning
Gordan
Published by: useruseruser on May 14, 2013 10:52Hello
useruseruser wrote:
Hi all
I have a large table with column:
the code, street, data_type, credit, debt, saldo, dateI created query as
sum (saldo), Select tableA where data_types = 1 and date code<'201010' group="" by="">'201010'>
but cannot develop this request to be in the report as
COLUMN1 COLUMN2 COLUMN3 COLUMN4
Sum (saldo) - where type = 1 and date = '201201', sum (saldo) where type = 2, sum (saldo) If date = '201205', codeWhat is the best solution for sums of report for diferent data_types on a single line with just one code per lines?
concerning
GordanPublished by: useruseruser on May 14, 2013 10:52
You can use CASE what
sum(saldo) -, sum(saldo) where type=2, sum(saldo) where date ='201205' , code select code, sum(case when type=1 and date = '201201' then saldo else 0 end) AS COLUMN1, sum(case when type=2 then saldo else 0 end) AS COLUMN2, sum(case when date ='201205' then saldo else 0 end) AS COLUMN3, sum(saldo) from tableA group by code
Concerning
Mr. Mahir Quluzade -
c.v. in the analytical report problem
Hi experts,
I have a new problem in the creation of the report on the c.v. of function, I think that some of you can help me out here.
I create a request as below:
months software_version number_of_machine
201001 100
201001 50
201002 200
201002 20
I want to get the sum of each version of the software, but we can not directly use abstract (number_of_machine) to get the right result
Anyone know what I should do to get the result?
Thank you very much!!!
XinHello
Try the c.v. with CLAUSE
Like this:
c.v. (software_version number_of_machine)Best regards
Laszlo -
Details of SQL query in AWR report
Hello
In the AWR report, I found that there are a few SQL with full table scan queries
How drill us in this topic and find which table have full analysis
Yes with Explain plan we can do but is there another way in Oracle 11g
Please let me know
See you soonKnight wrote:
In the AWR report, I found that there are a few SQL with full table scan queries
How drill us in this topic and find which table have full analysisYes with Explain plan we can do but is there another way in Oracle 11g
Please let me knowWhat, exactly, you look in the AWR report allowing you to decide that some SQL statements are complete tablescans but, at the same time, don't show you the tables that are being analyzed?
If the statement is visible in the SQL "order by...» "sections of report then execution plans and workloed for education is also in the AWR. You can access either from Enterprise Manager, either by running the report $ORACLE_HOME/rdbms/admin/awrsqrpt.sql.
Concerning
Jonathan Lewis
http://jonathanlewis.WordPress.com
Author: core Oracle -
SQL query using the MAX function
I am trying to display only those records where the "date_entered" is the most recent by case number.
Right now, it's the output im get.SELECT distinct c.case_number, u.email,c.assigneddate_chart, --m.date_entered, max(m.date_entered)as last_date_entered, trunc(sysdate)-trunc(c.assigneddate_chart)days_late, trunc(sysdate)-trunc(m.date_entered)addl_days_late from chart c, chart_user_roles u,comments m where (c.case_status IN ('Open','Pending')) and c.case_number=m.case_number group by c.case_number, u.email,c.assigneddate_chart,m.date_entered
Output:
CASE_NUMBER---EMAIL---ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
I am wanting to achieve this result:
Therefore, based on the data below, are the only records I am wanting to display:
[email protected]
[email protected]
Thank you
DeannaSELECT case_number, email, assigneddate_chart, date_entered, trunc(sysdate)-trunc(assigneddate_chart) days_late, trunc(sysdate)-trunc(date_entered) addl_days_late FROM ( SELECT c.case_number, u.email, c.assigneddate_chart, m.date_entered, dense_rank() over(partition by c.case_number order by m.date_entered DESC) rnk FROM chart c, chart_user_roles u, comments m WHERE c.case_status IN ('Open','Pending') AND c.case_number=m.case_number ) WHERE rnk = 1 /
SY.
-
between the clause of sql query?
Hi all
After sql query using a report.
------------------------------------------------
Select trunc (m.spc_doc_date) prod_date, sum (nvl(d.req_qty,0)) order_qty, sum (nvl(d.spc_item_qty,0)) prod_qty
of spc_ppc_daily_m m, spc_ppc_daily_d d
where m.spc_doc_ # in (select spc_doc_ # to spc_ppc_daily_m)
- and d.blce_qty > 0
and m.spc_locn_code =: locn_code
and m.spc_doc_date between: TO_date and: FROM_date
and m.spc_locn_code = d.spc_locn_code
and m.spc_doc_ #= d.spc_doc_ #.
and (m.obu =: obu OR: OLGA IS NULL)
and (m.customer =: customer OR: CUSTOMER IS NULL)
Trunc Group (m.spc_doc_date)
order of trunc (m.spc_doc_date)
-----------------------------------------
"When I use to_date = 22 February 2012 ' from_date = February 22, 2012"
There is no pick up. (acually documents are there on February 22, 2012)
"When I use to_date = 22 February 2012 ' from_date = February 23, 2012"
now shows data of February 22, 2012.
I have replace between it of > = & < =, same result two cases respectively.
Why?
Thank you
Yoanndate you hours minutes and seconds
thenuse
trunc (m.spc_doc_date)or to: from_date in the parameter after form convert to February 23, 2012 23:59:59 '
-
Hi team,
For example if I have a demo table with 4 columns (A, B, C, D) DEMO.
I want a report on this table, such that the report contains the headers and the Details section.
For each unique combination of (A, B) I must first of all show header based on the header information I want to display the detailed section.
In my header section I want to display 2 columns (A, B) that are common to the detailed section. Remaining 2 columns in the detailed section.
Here is an example: -.
A B C D
1 5 9 3
1 5P8
1 5 P O
1-5-9
1 8 9
1 D * /
2 8 33 P
2 P O O
2 P L L
YOU WILL SEE
A AND B
1 5
C D
9 3
P 8
P O
A AND B
1 D
C D
5 9
8 9
* /
A AND B
2 P
C D
8 33
O O
L L
Please suggest the solution (sql query) for above the problem and how to nest gernerated headers dynamically in the report area.
I use APEX 4.0
Any position in this regard is very significant.
Thanks and greetings
RajendraTry this:
SQL> select * from tab; 1 5 9 3 1 5 P 8 1 5 P O 1 D 5 9 1 D 8 9 1 P 8 3 1 P O O 7 rows selected. SQL> select a,b from (select r,a,b from ( select to_char(rownum)||'a' r, 'A' a,'B' b from (select distinct a, b from tab order by a,b)) union ( select to_char(rownum)||'c' r, 'C' c,'D' d from (select distinct a, b from tab order by a,b)) union ( select to_char(rownum)||'b' r, a,b from (select distinct a, b from tab order by a,b)) union select parent.r, tab.c, tab.d from ( select to_char(rownum)||'d' r, a,b from (select distinct a, b from tab order by a,b)) parent , tab where parent.a=tab.a and parent.b=tab.b ) order by r ; A B 1 5 C D 9 3 P 8 P O A B 1 D C D 5 9 8 9 A B 1 P C D 8 3 O O
-
Can I use session variables in data model BI publisher SQL query?
Hi Experts,
We apply security at the level of the BI Publisher 11g data.
In OBIEE we do so using session variables, so I wanted to just ask if we can use the same session variables in BI Publisher as well
That is, we can include a where clause in the SQL for the sample data as
Where ORG_ID = @{biServer.variables ['NQ_SESSION.]} {[INV_ORG']}
I would like to know your opinion on this.
PS: We implement security EBS r12 in BI Publisher.
Thank youRead this-> OBIEE 11 g: error: "[nQSError: 23006] the session variable, NQ_SESSION.» LAN_INT, has no definition of value. "When you create a SQL query using the session NQ_SESSION variable. LAN_INT in BI Publisher [ID 1511676.1]
Follow the ER - BUG: 13607750 -NEED TO be able TO SET up a SESSION IN OBIEE VARIABLE AND use it IN BI PUBLISHER
HTH,
SVS -
Hello
I have to generate a report that contains a query with the database link. This database link is not pre-programmed and would be taken up in another report which contans a link to this report. If this link value of database for the query could be. Can someone guide me hot to write a dynamic select statement so that I could add value of binding of database running.
Thank you
SalmanHello Salman,
You must create a report of "query SQL (PL/SQL function body return SQL query. If you create a normal report of SQL query (using any SQL statement you like - example 1 SELECT FROM DUAL), you can then change the Type of report to this parameter.
Once this is done, you can then create a string that will build the SQL query, you must - what is done when entering the parameter Source in the region in the region to replace the PL/SQL code. How this string is constructed depends on where your data is and so on, but it's just a case of gettnig correct information and concatenated into a single string that forms the SELECT statement.
For example:
DECLARE vTABLE VARCHAR2(100); vSQL VARCHAR2(1000); BEGIN vTABLE := 'MYTABLE@OTHERDB'; vSQL := 'SELECT * FROM ' || vTABLE; RETURN vSQL; END;
The PL/SQL above to build a string:
SELECT * FROM MYTABLE@OTHERDB
who then returned to Apex to generate the report. Also you should probably select the option "use generic column names (analysis of query runtime only)" under this.
Andy
-
A map of OWB (service line) SQL query
If I trace a session, run a map OWB (base line), the trace file contains the actual SQL query?
The problem with me is that when I execute this rank - based OWB card, is throw me an error CursorFetchMapTerminationRTV20007, BUT (most time consuming) when I take on the intermediate SQL insert query, it works very well (and also in a very short time)
The executing State = COMPLETE
message = text ORA-06502: PL/SQL: digital or value error: character string buffer too small
CursorFetchMapTerminationRTV20007 = message text
N ° of task errors = 0
N ° task warnings = 2
N ° errors = 1
Since this card OWB (truncate insert) is the line in function of where I can't back-end of the generated pl/sql package request OWB so I was wondering if I trace the session, check the trace file, maybe I'll able to see the exact SQL query generated. But I wanted to confirm the same.
Yes, the real run SQL in session will be in the trace file.
Maybe you are looking for
-
How to exclude programs that I use rarely loading at startup and slows down the startup?
-
OUTLOOK EXPRESS 6 going out e-mail questions
Hello, I have Outlook Express 6, I can receive emails, but cannot send them, my account would have the wrong settings, please help. Thank you
-
Windows Media won't play a DVD
How com windows media won't play a dvd, even with a decoder, I added this morning?
-
Vista recognizes a CD that isn't here
I finished my burning process to put my pictures on a CD through Windows vista explore. I have read many many forums that talk about the disc "finalize" automatically during the ejection. My computer will not automatically eject the station CD burnin
-
Cisco AnyConnect 2.5.1025 on Win7 x 64 Ultimate edition (SP1)
Dear Sirs and Madams, I experience hard attempts to establish a VPN connection in above mentioned environment on a UMTS device (which works fine on my X 61, running Win7 x 64 Enterprise (SP1)). VPN session is launched, research for client-config (/ d