SQL & PL/SQL :: Summary Column To Details?
Sep 25, 2011I have one table which has two columns name,qty and it has data like arif,3 pcs i want to display it in 3 lines if the qty is 3 and in 2 lines if the qty is 2 using sql query
View 6 RepliesI have one table which has two columns name,qty and it has data like arif,3 pcs i want to display it in 3 lines if the qty is 3 and in 2 lines if the qty is 2 using sql query
View 6 Replies SQL summary for below data:
Table: temp_user_access
NAME Null? Type
------------------------------- --------- -----
USERGROUP VARCHAR2(255)
USERNAME NOT NULL VARCHAR2(40)
NICKNAME VARCHAR2(40)
AAACC VARCHAR2(70)
SYSTEM VARCHAR2(10)
I need the expected result as per attached photo
I have tables dynamically created with dynamic number of columns. There will be 7 columns that would always be fixed with their names and data types. They will always be last 7 columns.
way to write a select statement on those dynamic tables where only those known 7 columns are not selected and I need to select all the rest columns but leave the 7 columns names I know.
In details table i am having loc is column in which data is like this(Jones,180),(US,host name),(job, company),(id,0122)
output should be it should take only first value from ().
I was looking for application column name corresponding to "Draft Invoice Number" ra_interface_lines_all table.
I tried the below.
/* Get descriptive_flexfield_name for the application table name*/
SELECT *
FROM FND_DESCRIPTIVE_FLEXS_VL
WHERE application_id = 222
AND APPLICATION_TABLE_NAME=upper('ra_interface_lines_all');
/* Get the application column name and end user column name*/
SELECT *
FROM FND_DESCR_FLEX_COLUMN_USAGES
WHERE application_id = 222
AND descriptive_flexfield_name = 'RA_INTERFACE_LINES';
There are many DESCRIPTIVE_FLEX_CONTEXT_CODEs obtained. I could finally trace out that draft invoice number corresponds to INTERFACE_LINE_ATTRIBUTE2. How can I know what DESCRIPTIVE_FLEX_CONTEXT_CODE should I look for?
I want to build a single query to fetch the application column name and flex field name for a specific table .
this is my table
create table sequence ( id int not null primary key);
insert into sequence(id) values
(1), (2), (3), (4), (6), (7), (8), (9),
(10), (15), (16), (17), (18), (19), (20),(22);
i need the answer to group the sequence like this
start_number | end_number | count
1 | 4 | 4
6 | 10 | 5
15 | 20 | 6
22 | 22 | 1
what should i do?
this is my table
create table sequence (
id int not null primary key
);
insert into sequence(id) values
(1), (2), (3), (4), (6), (7), (8), (9),
(10), (15), (16), (17), (18), (19), (20),(22);
i need the answer to group the sequence like this
start_number | end_number | count
1 | 4 | 4
6 | 10 | 5
15 | 20 | 6
22 | 22 | 1
what should i do?
I brought in the Northwind database 2003 in to SQL Developer. I was looking at the view 'Summary of Sales by Quarter' But this report brings in everything. It doesent give me summary of sales for Qtr1, Qtr4 etc
These are the columns:
ShippedDate
OrderId
Subtotal
CREATE OR REPLACE FORCE VIEW "NORTHWIND"."SUMMARY_OF_SALES_BY_QUARTER" ("SHIPPEDDATE", "ORDERID", "SUBTOTAL")
AS
[code]....
How can i recreate this view to show me summary data for qtr1, qtr2, qtr3 and qtr 4 for the year 1997??
I have been sweating on this since the weekend.
My source table
SELECT
'182383' EMPLOYEE_NO
, 'ABACUS' FULL_NAME
, 'ADMIN' DEPARTMENT
, 'ADMIN' PREV_DEPARTMENT
, TO_DATE(20090104,'YYYYMMDD') EMP_START_DATE
[Code]....
EFFECTIVE_START_DATE: SCD field, Date ABACUS moves from one department to another.
EFFECTIVE_END_DATE: SCD field, Date ABACUS left the department from another. To keep history of movement.
The sample report shows possible scenario on my data.
I want to build monthly report to cater from departmental headcount on monthly basis, starting from from ABACUS start date.
see sample report below
MONTH | DEPARTMENT |NEW_HIRES | RELOCATION (OUT) | RELOCATION (IN) | NET TOTAL PREV MONTH | NET TOTAL PRESENT MONTH |
WHERE
MONTH: REPORT MONTH
DEPARTMENT: THE DEPARTMENTS IN THE ORGANIZATION
NEW_HIRES: NUMBER OF NEW STAFFS HIRED THAT MONTH BASE ON EMP_START_DATE
RELOCATION_OUT: NUMBER OF STAFFS MOVEMENT TO ANOTHER DEPARTMENT (EMP_END_DATE IS NULL, EFFECTIVE_START_DATE AND
[Code]....
I have a below requirement from client.
Create a procedure generate_daily_session_summary that will read the pcm_session_summary (pk sess_id) table and create a per day summary in the pcm_session_summary_daily table.
1. Summarize all records from pcm_session_summary for session start timestamp (START_TS) greater than the max existing SESS_DT from pcm_session_summary_daily table and less than the start of current day. Insert the records into the pcm_session_summary_daily table.
2. Populate the fields in pcm_session_summary_daily as follows :
sess_dt - truncated date from pcm_session_summary.start_ts unique_user_cnt - count of unique cws ids encountered in that day, sess_cnt number - count of total sessions in that day , max_concurrent_sess_cnt number - maximum number of concurrent sessions at any point of time in that day. Concurrent sessions are defined as those that have overlapping start_ts or end_ts - sessions that were active at the same moment in time would be concurrent with each other.
3. The procedure will be scheduled to run every day in a batch job and will summarize session data until the end of the previous day
I have the table with below details.
desc PCM_SESSION_SUMMARY
Name Null Type
---------- -------- ------------
SESS_ID NOT NULL NUMBER
USER_CUPID VARCHAR2(10)
START_TS TIMESTAMP(6)
END_TS TIMESTAMP(6)
ACT_CNT NUMBER
[code]....
I have written the below query to get the result for question no:1
select trunc(start_ts,'DDD') start_ts,count(distinct(user_cupid)) user_cnt,count(SESS_ID) Sess_cnt
from PCM_SESSION_SUMMARY
where START_TS < sysdate or START_TS > (select max(sess_dt) from pcm_session_summary_daily where sess_dt < sysdate)
group by trunc(start_ts,'DDD')
order by start_ts;
However i tried a lot but not sure how to get maximum concurrent session count for a day.One of my friend comment below.
The Pcm_session_summary_daily is empty so you need to handle nulls when doing max. That will fix the issue of no results for the Greater Than condition.
You need to get concurrent count of sessions with respect to one another, the query that you have will not work. Do it in PL/SQL using procedural logic. The queries would return multiple rows, you need to handle that.
Why cant oracle give an extra parameter for summary function like MAX and MIN...For example
select max(salary,2)
from empWill give the second max salary.
I've been experiencing strange Oracle behavior from time to time when using "explain plan". what could be the reason? (I'm going to create an Oracle ticket when I could find the cause...)
The total cost of a query was low (ex. ~500) while sub-parts of the query has high cost (ex. ~10000).I don't want to provide the query itself as the issue is observed for huge queries (like 2M characters!).The execution plan looks like this:
+- SELECT STATEMENT , ALL_ROWS, Cost 736
|
+--+- WINDOW SORT , Cost 736
|
[code]...
we have just upgraded discoverer from 3.1 to 4.1
and we click on create summary folders we got this error Summary management not available because : this user has no privilige or quota to create materialized view in the current schema External summary registeration not available because : this user has no privilige or quota to create materialized view in the current schema
altough i granted privilige for materialized view
I have one group wise report and my requirement is i need to print both the Outputs in one single report first, is group with details and the summary in the last page showing machine code and summary of qty as totals ,I have given below test case .
create table ot_cut_detail (mach_code varchar2(12),batch_code varchar2(12),pos_no varchar2(12),pos_qty number)
insert into ot_cut_detail values ('L1','01','1001',2);
insert into ot_cut_detail values ('L1','01','1002',2);
insert into ot_cut_detail values ('L1','01','1003',2);
insert into ot_cut_detail values ('L2','01','1004',2);
insert into ot_cut_detail values ('L2','01','1005',2);
SQL> SELECT * FROM OT_CUT_DETAIL;
MACH_CODE BATCH_CODE POS_NO POS_QTY
------------ ------------ ------------ ---------
L1 01 1001 2
L1 01 1002 2
L1 01 1003 2
L2 01 1004 2
L2 01 1005 2
--Detailed output is like this as below
MACH_CODE BATCH_CODE POS_NO A
------------ ------------ ------------ ---------
L1 01 1001 2
1002 2
1003 2
L1 Total 6
L2 01 1004 2
1005 2
L2 Total 4
Grand 10
--Summary report will be as below both in one report.
MACH_CODE BATCH_CODE totals
------------ ------------ ---------
L2 01 4
L1 01 6
I'm wanting to create a query that will give me a summary of parts and labor from work orders. However there are three tables. work_order, parts, labor. Sometimes there will only be parts, sometimes just labor, or sometimes both. Well my query will only return results when they are on both. Sample query is below. Do I need to create a temp table to gather the data or is there a way to do this with a sub query.
select work_order.wono, sum(parts.cost), sum(labor.cost)
from work_order, parts, labor
where
work_order.wono = parts.wono and
work_order.wono = labor.wono
group by work_order.wono;
I have a datablock like this
datablock name : jou_tra1_tab
No. of record dispalyed is 5
so datablock display like this
jtt_amt jtt_amt_1 ck_amt
jtt_amt jtt_amt_1 ck_amt
jtt_amt jtt_amt_1 ck_amt
jtt_amt jtt_amt_1 ck_amt
jtt_amt jtt_amt_1 ck_amt
----------------------------
ck_amt_tot
ck_amt is checkbox..
ck_amt_tot is total of jtt_amt_1 [but total only those record whose checkbox is checked]
My task is like this When i checked checkbox whatever value in jtt_amt transfer to jtt_amt_1 field
but i can change value in jtt_amt_1 field ...i want to take addition of that changed field and show that sumation in ck_amt_tot.
I write trigger when-checkbox-changed like this
-------------------------------------------------
IF :jou_tra1_tab.ck_amt = 'Y' THEN
set_item_INSTANCE_property ('jou_tra1_tab.jtt_amt_1',CURRENT_RECORD, UPDATE_ALLOWED, PROPERTY_TRUE);
:jou_tra1_tab.jtt_amt_1 := :jou_tra1_tab.jtt_amt;
else
:jou_tra1_tab.jtt_amt_1 := 0;
END IF;
and when validation item trigger for jtt_amt_1 :
--------------------------------------------------
IF :jou_tra1_tab.ck_amt = 'Y' then
:jou_tra1_tab.ck_amt_tot := :jou_tra1_tab.ck_amt_tot + :jtt_amt_1 ;
else
:jou_tra1_tab.ck_amt_tot := :jou_tra1_tab.ck_amt_tot - :jtt_amt_1 ;
But when i changed value in jtt_amt_1 field i cant get write summation .
how to put exceptions while defining the summary item ? In one of my datablock there are certain lines whose "inactive_flag" gets a "Y" value on certain events. I want my summary item to exclude such amounts from summing up.
View 3 Replies View RelatedI have got another curly one with regard to Sql Loader. My original issue via [message #513696] was resolved. In summary, SQL Loader opens a comma delimited csv file and it is able to successfully populate the appropriate Oracle table. However, during the run to process each unique csv file, SQL Loader produces a both a .log file (indicating what transpired during the load) and a .bad file of the records from the csv file that where rejected by SQL Loader.
the users have requested that "is it possible to update a separate table of the summary results of what went wrong and what was right?" It just so happens that the csv file contains some summary records (rows) with processing audit infor...as the following .bad file wrote out....
___________________________
ModuleID,ModuleSN,Lat,Lon,GMT Time,Tag Count,GMT Date,Client,Farm,Field,Variety,Machine
No Module ID ,No SN ,-30.178958,149.63844,9:55:58,0,21/04/2011,101,Widgen ,9,71BRF ,5987
3500B9880611170260179BFB,10202094587,-30.199379,149.661333,7:10:35,2,22/04/2011,101,Widgen ,30,71BRF ,5987
,,,,,,,,,,,
Total Modules,1602,,,,,,,,,,
Mis-reads,1,,,,,,,,,,
Mis-read %,0.06,,,,,,,,,,
1. The first record (starting in the 1st postion is "ModuleID") is a heading record in the csv file and can be disregarded.
2. The secord record (starting in the 1st postion is "No Module ID") is an error record in the csv file and can be disregarded.
3. The third record (starting in the 1st postion 3500B9880611170260179BFB, ) is a valid record, however, is was rejected as it is a duplicate of a preceeding record ...and the log indicates ...
Record 124: Rejected - Error on table PTLIVE.MODULE_CSV_LOADS.
ORA-00001: unique constraint (PTLIVE.MODULE_SERIAL_NUMBER_UK) violated
4. The fourth record (starting in the 1st postion is ,,,,,,,,,,,
) is a blank record in the csv file and can be disregarded.
5. The fifth record (starting in the 1st postion is "Total Modules" has a value of 1602 which I need to capture to write into a separate table.
6. The sixth record (starting in the 1st postion is "Mis-reads" ) has a value of 1 which I need to capture to write into a separate table.
7. The last record in the csv file and can be disregarded.
The summary Oracle table is
CREATE TABLE PTLIVE.SUBMODULES_SUMMARY
( IMPORT_CSV_FILE_NAME VARCHAR2(256 ),
TOTAL_SUBMODULES_LOADED NUMBER (5),
TOTAL_SUBMODULES_MIS_READ NUMVER (5),
DATEIMPORTED DATE default SYSDATE
)
Now I would like to trap the value 1602 and load that into the Oracle column TOTAL_SUBMODULES_LOADED and the value 1 and load this into TOTAL_SUBMODULES_MIS_READ.
The name of the csv file is known and I can (as the previous [message #513696] resolved) simply use a SQL Loader control file command > IMPORT_ CSV_FILE_NAME CONSTANT "Batch_2011Jun29_TEST.csv".
See my data
Location--------Employee-------------Sales-----------------------Sales per emp
1------------------ 4-----------------------100------------------------------25
2------------------ 5-----------------------120------------------------------20
3------------------ 7-----------------------210------------------------------30
Total---------------16-----------------------430-----------------------------27
The total 27 achieve by (430/16)=27 How can I get using ORacle BI Discoverer 11g Desktop
how can i monitor the instance status and log switch summary.
View 8 Replies View RelatedI have to breakdown the sum of qty into each line as single piece ,as example below how to achieve this using sql as i am doing it using a procedure.
CREATE TABLE OT_CUT_ITEM
(
CTI_SYS_ID NUMBER,
CTI_ITEM_CODE VARCHAR2(30 BYTE),
CTI_LEN NUMBER,
CTI_QTY NUMBER
);
[code]....
output required is
CTI_SYS_ID CTI_ITEM_CODE CTI_LEN CTI_QTY
---------- ------------------------------ ---------- ----------
1 A 7000 1
1 A 7000 1
1 A 7000 1
1 A 7000 1
2 B 6000 1
[code]....
I have a user in my oracle database, I would like to know details such as, how many times and by using which tools same user has got logged for past one week.
How do I do that. I have sql which shows the current session either he is logged in, if so then which application or not logged in. But I required the information for past one week How do I get those details.
I want to save ip address, os username, terminal information at the time of record insertion/updation therefore I am using sys_context function but it gives me error at the time of form compilation.
ERROR:
ORA-00600: internal error code, arguments: [17069],[134386616],[],[],[],[],[],[]
My user has already DBA privilege.
In our project we have many instance running with Oracle in one solaris zone. We are in the process of cost reduction so planning to bring the CPU in shared pool and reduce them.
if we can bring all the NUP (Named user Perception) CPU on one shared pool. Will it be cost effective and is there any problems in performing such change.
How can I find out a user session/connection details like ( his last connection time, his activity etc)
Here is the issue, a old dba_user_id who physically no longer exists is not removed from the database. At some time, a session is opened under his user_id and some activity runs and closes the session. So, checked scheduled jobs under him and disabled them. But not sure whether the scheduled jobs are creating a session under his user_id or some thing else.
I checked in v$session, but since I am not sure at what time his session opens, so I am not able to get his session details.
In AWR Report i found that there are few SQL queries that have full table scans how can we drill about this and find which table have full scan
yes with Explain plan we can do this but is there any other way in Oracle 11g
when the tables are updated, the following detals must be correct to ensure that the links in the affected tables are in place.
PLUPDATE_NEW(PLUP_SAVE_SEQ field value) must be the same with PLUPDATE_BENEF_NEW (PLUP_NEW_BENEF_SAVE_SEQ field value)
PLUPDATE_OLD(PLUP_SAVE_SEQ field value) must be the same with PLUPDATE_BENEF_OLD (PLUP_OLD_BENEF_SAVE_SEQ field value)?
[Code]....
i tried this code, what should i do in the link for this tables?
i want to display employees details when i am passing Deptno and that department employees only display in Oracle Forms
View 16 Replies View RelatedUnder what userid(privileges) does a scheduled DBMS Jos run, is it under the same user that scheduled the job?
Does oracle internally log in(opens a new session) in order to run a scheduled DBMS Job?
some reference websites where I can get some details about how the scheduled jobs are executed?
When I execute my form, on pressing key F5 it displays the all available block names in the form. I want to restrict this.
View 5 Replies View Related