Query to retrieve the number of transactions in every 1 hour for the end
HelloCould someone help to write a query to retrieve the number of transactions in every hour for the last month.
Case:
I / P
If Timestamp1
1 01/01/2008 00:00:01
CAS2 01/01/2008 00:01:01
case3 01/01/2008 01:00:01
1 01/01/2008 01:02:01
case4 01/01/2008 01:10:01
Service5 01/02/2008 02:00:01
Case6 01/02/2008 02:10:01
case7 2008-02-01 23:00:01
.............................
.............................
case... 2008-01-31 00:24:00
O/P
cases of to_time of time
2008-01-01 00:00:00 01/01/2008 01:00 2
2008-01-01 01:00:01 01/01/2008 02:00 3
.........................
.........................
etc.
Any help really appreciated
We can do this by using analytic functions
Here's what I did:
create table timestamp1 (date of ts)
Select * from timestamp1
2008-10-30 15:41:13
2008-10-30 15:41:05
2008-10-30 15:40:03
2008-10-30 14:58:26
2008-10-30 14:29:45
2008-10-30 13:17:48
2008-10-30 08:29:50
2008-10-30 06:05:51
2008-10-30 03:41:52
2008-10-30 02:29:54
Select distinct to_char (ts, 'hh24') frmhrs,
TO_CHAR (ts, 'hh24') + 1 tohrs, count (ts) OVER (order by to_number (to_char (ts, 'hh24')) RANK BEFORE (1/24))
of timestamp1
When trunc (ts) = trunc (sysdate) - I added this just to make sure that I get for data of today
order of frmhrs
FRMHRS TOHRS CNT
1-3-02
03-4-1
06 7 1
1-9-08
13 14 1
14 15 2
15 16 3
You can customizeas by your need.
Tags: Database
Similar Questions
-
Query to retrieve the latest version
Hello
I am trying to create a query that retrieves the latetst of a product version. There are 2 tables I have mark from, we have the product number and we got the version - a varchar2 data type (60). Are versions A, B, c... etc. So, I want to give me a line for each product with its latest version of the application. It's the query I have so far
SELECT A0. Prod_num, A0.version
FROM (SELECT A0B. Prod_num, A0.version
Of tb_1 A0, tb_2 A0B
WHERE (A0.tb_1pk = A0B.tb_2pk)) A0
ranking by A0. Prod_num
Returns duplicate versions and product lines.
Thank you.Without seeing sample data...
SELECT A0B. Prod_num,
Max (a0.version)
Of tb_1 A0, tb_2 A0B
WHERE (A0.tb_1pk = A0B.tb_2pk)
AO8.prod_num GROUP; -
Query to retrieve the level 2 supervisors
Hi all
I use the following query to retrieve the people which is under the supervision of a given person_id... Is it possible to modify this query (see below) in order to get two levels of employees? something like:
Supervisor 1
Employee 1
Employee 2
Employee 3
Supervisor 2
Employee 4
Employee 5
Employee 6
The query works if I pass the person_id 1 for example supervisor that I would get used 1 2 and 3. But if I pass an id of the person who, of higher hierarchy, I will just get supervisor 1 supervisor 2... And I need all the people (just two levels down)
Select distinct *)
Select distinct ppf.first_name |' '|| PPF.last_name
ppf.last_name
fu.user_name
fu.user_id
ppf.person_id
papf.person_id Manager
pi.image_id
initcap (hla.description) LOCATION
pb.NAME pay_basis_name
pax.grade_id
haou.name
employment_category
ppos.date_start
of per_assignments_x pax
per_grade_definitions pgd
per_people_x WP
fnd_user fu
per_all_people_f women's wear
per_images pi
hr_locations_all hla
per_pay_bases pb
hr_all_organization_units haou
per_periods_of_service OPP
where ppf.person_id = pax.person_id
and trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
and fu.person_party_id = papf.party_id
and pax.supervisor_id = papf.person_id
and pi.parent_id (+) = ppf.person_id
and pi.table_name (+) = "PER_PEOPLE_F".
and pax.person_id = ppf.person_id
and hla.location_id (+) = pax.location_id
AND ppf.current_employee_flag = 'Y '.
AND pb.pay_basis_id = pax.pay_basis_id
AND haou.organization_id = pax.organization_id
AND ppos.person_id = ppf.person_id
AND pax.grade_id = pgd.grade_definition_id
AND papf.person_id =: inPersonId
UNION ALL
Select ppf.first_name |' '|| PPF.last_name
ppf.last_name
fu.user_name
fu.user_id
ppf.person_id
papf.person_id Manager
pi.image_id
initcap (hla.description) LOCATION
pb.NAME pay_basis_name
pax.grade_id
haou.name
employment_category
ppos.date_start
of per_people_x WP
per_grade_definitions pgd
fnd_user fu
per_all_people_f women's wear
HR_WORKING_PERSON_LISTS HWPL
per_images pi
per_assignments_x pax
hr_locations_all hla
per_pay_bases pb
hr_all_organization_units haou
per_periods_of_service OPP
where
trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
and fu.person_party_id = papf.party_id
AND HWPL.owning_person_id = papf.person_id
and hwpl.selected_person_id = ppf.person_id
AND pi.parent_id (+) = ppf.person_id
and ppf.current_employee_flag = 'Y '.
and pax.person_id = ppf.person_id
AND hla.location_id (+) = pax.location_id
AND pb.pay_basis_id = pax.pay_basis_id
AND haou.organization_id = pax.organization_id
AND ppos.person_id = ppf.person_id
AND pax.grade_id = pgd.grade_definition_id
AND papf.person_id =: inPersonId
) order of last_nameHello Alejandro,
You can play a little bit with one below with what you find most comfortable.
/ * multi level * /.
Select the level
assignment_number
assignment_id
Manager
, (select full_name from per_people_x where person_id = pax.person_id)
, sys_connect_by_path ((sélectionnez employee_number dans per_people_x où person_id = pax.person_id), '-->')
of per_assignments_x pax
where primary_flag = 'Y '.
connect by prior person_id = Manager
Start by person_id = 1523/ * level 2 only * /.
Select (select full_name from per_people_x where person_id = pax1.person_id)
, (select full_name from per_people_x where person_id = pax2.person_id)
of per_assignments_x pax1
per_assignments_x pax2
where pax1.supervisor_id = 1523
and pax1.primary_flag = 'Y '.
and pax1.person_id = pax2.supervisor_id
and pax2.primary_flag = 'Y '. -
SQL query to retrieve the same record because no. boxes
Hi all
I have a table of Bill XXINV.
the columns are
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1123 XXITEM2 2 6
I can do a sql query so that I can retrieve the same records repeated as number INVH_BOXES.
Select * from XXINV
where invh_no = 1122
output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
Desired output:
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
1122 XXITEM1 1 5
or
INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES
1122 XXITEM1 1 1 of 5
1122 XXITEM1 1 2 of 5
1122 1 3 5 XXITEM1
1122 XXITEM1 1 4 of 5
1122 XXITEM1 1 5 of 5
Please suggest. Like I need to print each line in a single page to stick them on boxes so that packaging.
Kind regards
Afzal.
Just add INVH_ITEM_CODE to the connection by the clause.
Select invh_no
invh_item_code
invh_qty
to_char (, 'fm99') | 'from ' | TO_CHAR (invh_boxes, 'fm99') invh_boxes
of xxinv
where invh_no = 1122
connect
by level<=>=>
and prior invh_item_code = invh_item_code
and prior sys_guid() is not null
-
Query to retrieve the data in a sort of pivot format.
Hello gurus of PL/SQL,.
I need to extract the data in a format some tables using the join condition. When I extracted using simple join then it turn around individual records based on condition, but want it in a particular format only.
When run the query-
Select sf. JOIN_DT_KEY, sd. CLS, sd. CLS_STATUS, sf. CLS_QTY, sf. CLS_FEES,
SF. TOTAL_AMT
of stud_det_fact sf, sd, cd class_dim stud_tag_dim
where sf.stud_dim_key = sd.stud_dim_key
AND sf.alloc_cls_dim_key = d.alloc_cls_dim_key AND sd. CLS_STATUS IN
("BA", "BSC", "MA", "MBA", "SMC")
AND af. JOIN_DT_KEY between 20120404 and 20120410 ORDER BY sd. CLS
That the data is returned in the following format:
JOIN_DT_KEY CC CLS_STATUS CLS_QTY CLS_FEES TOTAL_AMT
1 20120404 BA 1050000 12 875 WORK
2 20120404 BA 125 12 150000 CAPITAL
3 20120404 BA 1050000 12 875 WORK
4 20120404 BSC 4 10 4000 CAPITAL
5 20120404 BSC 3 10 3000 CAPITAL
6 20120404 MY 1050000 12 875 WORK
7 20120404 MY 1000 12 1200000 WORK
8 20120404 MBA 1200000 12 1000 ALGO
9 20120404 MBA 1200000 12 1000 ALGO
But I want to in the format after using query itself.
JOIN_DT_KEY WORK of CLS (Qty) WORK (Amt) CAPITAL (Qty) CAPITAL (Amt) (Qty) ALGO ALGO (Amt) NATURAL (Qty) NATURAL (Amt) GrandTotal (Qty) GrandTotal (Amt)
20120404 1750 2100000 125 150000 0 0 0 0 1875 2250000 BA
0 0 7 7000 BSC 0 0 0
0 7 7000
MY 1875 2250000 0 0 0 0 0
0 1875 2250000
0 0 0 0 2000 2400000 MBA 0
2400000 2000 0
3625 total 4350000 132 157000 2000 2400000 0
0 6907000 of 5757
How to change the query to get the hinge of the sort of result, kindly help me. I appreciate all your help in advance.
Thank you and I really apperciate your help.
Note:-attached, this is the example of excel sheet.
Published by: user555994 on April 26, 2012 03:43I suggest that to take advantage of the Oracle version you have.
To start, I took your first message and created a few sample data. This is not your original tables, but it allows us to compare the results.
drop table T; create table T(JOIN_DT_KEY, CLS, STATUS, QTY, FEES, AMT) as select TO_DATE('20120404', 'YYYYMMDD'), 'BA', 'WORKING', 875, 12, 1050000 from dual union all select TO_DATE('20120404', 'YYYYMMDD'), 'BA', 'CAPITAL', 125, 12, 150000 from DUAL union all select TO_DATE('20120404', 'YYYYMMDD'), 'BA', 'WORKING', 875, 12, 1050000 from dual union all select TO_DATE('20120404', 'YYYYMMDD'), 'BSC', 'CAPITAL', 4, 10, 4000 from DUAL union all select TO_DATE('20120404', 'YYYYMMDD'), 'BSC', 'CAPITAL', 3, 10, 3000 from dual union all select TO_DATE('20120404', 'YYYYMMDD'), 'MA', 'WORKING', 875, 12, 1050000 from DUAL union all select TO_DATE('20120404', 'YYYYMMDD'), 'MA', 'WORKING', 1000, 12, 1200000 from DUAL union all select TO_DATE('20120404', 'YYYYMMDD'), 'MBA', 'ALGO', 1000, 12, 1200000 from DUAL union all select TO_DATE('20120404', 'YYYYMMDD'), 'MBA', 'ALGO', 1000, 12, 1200000 from DUAL;
To test the following against your data, is taken your SELECT in the right place or create a view and plug the display where I have the table "T".
Now, here's how to get everything except the last line "Total":
select * from ( select JOIN_DT_KEY, CLS, STATUS, QTY, AMT from t ) PIVOT(SUM(QTY) QTY, SUM(AMT) AMT for STATUS in('ALGO' as ALGO,'CAPITAL' as CAPITAL,'DMA' as DMA,'NATURAL' as natural,'WORKING' as WORKING)); JOIN_DT_KEY CLS ALGO_QTY ALGO_AMT CAPITAL_QTY CAPITAL_AMT DMA_QTY DMA_AMT NATURAL_QTY NATURAL_AMT WORKING_QTY WORKING_AMT ------------------ --- -------- -------- ----------- ----------- ------- ------- ----------- ----------- ----------- ----------- 2012/04/04 00:00 BSC 7 7000 2012/04/04 00:00 BA 125 150000 1750 2100000 2012/04/04 00:00 MBA 2000 2400000 2012/04/04 00:00 MA 1875 2250000
To get the latest "Total" line, you need to do another GROUP after the pivot.
select JOIN_DT_KEY, nvl(CLS, 'Total') cls, SUM(ALGO_QTY) ALGO_QTY, SUM(ALGO_AMT) ALGO_AMT, SUM(CAPITAL_QTY) CAPITAL_QTY, SUM(CAPITAL_AMT) CAPITAL_AMT, SUM(DMA_QTY) DMA_QTY, SUM(DMA_AMT) DMA_AMT, SUM(NATURAL_QTY) NATURAL_QTY, SUM(NATURAL_AMT) NATURAL_AMT, SUM(WORKING_QTY) WORKING_QTY, SUM(working_AMT) working_AMT from ( select JOIN_DT_KEY, CLS, STATUS, QTY, AMT from t ) PIVOT(SUM(QTY) QTY, SUM(AMT) AMT for STATUS in('ALGO' as ALGO,'CAPITAL' as CAPITAL,'DMA' as DMA,'NATURAL' as natural,'WORKING' as WORKING)) group by grouping sets((join_dt_key, cls), join_dt_key); JOIN_DT_KEY CLS ALGO_QTY ALGO_AMT CAPITAL_QTY CAPITAL_AMT DMA_QTY DMA_AMT NATURAL_QTY NATURAL_AMT WORKING_QTY WORKING_AMT ------------------ ----- -------- -------- ----------- ----------- ------- ------- ----------- ----------- ----------- ----------- 2012/04/04 00:00 BA 125 150000 1750 2100000 2012/04/04 00:00 MA 1875 2250000 2012/04/04 00:00 BSC 7 7000 2012/04/04 00:00 MBA 2000 2400000 2012/04/04 00:00 Total 2000 2400000 132 157000 3625 4350000
Using "grouping sets", you group by join_dt_key and cls (which the PIVOT is already done, but you have to do it again) and then by join_dt_key to get the total line.
Note: I suppose you want a total by date. If you want just a total general for all dates, then Group Rollup (join_dt_key, cls)).
I hope it's accurate and useful.
-
Query to retrieve the data according to requirement
Hi team,
I have the table with the details below and my requirement is when I entered the correct empid then only need to display recording (it's easy) and when I entered the empid that is not listed in the table, then I need to display all the records available in this table. Please give me the query.
EmpID ename
7839 KING 7698 BLAKE 7782 CLARK 7566 JONES 7788 SCOTT 7902 FORD 7369 SMITH Kind regards
Anil
can you please mark it as answered@user575819
-
Query to retrieve the average growth rate
Hi all
10.2.0.5 on solaris
Table script:
DB_SPACE_HIST
(
DATE TIME STAMP,
TOTAL_SPACE NUMBER (8).
USED_SPACE NUMBER (8).
FREE_SPACE NUMBER (8).
PCT_INUSE NUMBER (5.2).
NUM_DB_FILES NUMBER (5)
);
Sample data:
Timestamp: / 16/2010 12:57:52 AM
Totak space: 678017
Used space: 235612
Free space: 442405
PCT in use: 34.75
number of files: 60
We have the timestamp stored in the table for more than 3 years. The requirement is that we get the average growth in the database per month.
No idea how I can do this?
KaiStart by getting your data used_space by month:
select trunc(timestamp,'MM') mth, max(used_space) used_space_end_mth from db_space_hist group by trunc(timestamp,'MM');
Then you can use the analytic function LAG to get used_space_end_mth compared to the month previous for calculating growth:
select mth, used_space_end_mth - lag(used_space_end_mth) over (order by mth) growth from ( select trunc(timestamp,'MM') mth, max(used_space) used_space_end_mth from db_space_hist group by trunc(timestamp,'MM') ) order by mth;
And finally, you can simply select the average growth:
select avg(growth) avg_growth from ( select mth, used_space_end_mth - lag(used_space_end_mth) over (order by mth) growth from ( select trunc(timestamp,'MM') mth, max(used_space) used_space_end_mth from db_space_hist group by trunc(timestamp,'MM') ) );
-
Need of a query to retrieve the data
Hello
I have a table named person. It has two fields A_ID and B_ID. The table does not have a primary key
The data in the table are the following
A_ID B_ID_ _
1 5
1 10
2 5
2 10
4 15
5 20
I need to select A_ID and B_ID data so that when you select a given allocation A_ID or B_ID is not for more choices
For Eg: I select the first pair of 1 and 5. Then 1 and 5 is not in the selection of data from A_ID or B_ID
The output of the query for the data in the table above should be
Output
A_ID B_ID_ _
1 5
2 10
4 15
Hope you understand the situation.
Can someone help me to create a query for me
Thanks in advance
Published by: user599079 on August 12, 2009 21:40This done:
Nope:
SQL> with t as ( select 1 a_id, 5 b_id from dual union all select 1, 10 from dual union all select 2, 5 from dual union all select 2, 10 from dual union all select 4, 15 from dual union all select 5, 6 from dual union all select 6, 9 from dual ), union_data as ( select a_id as id , 'A' as col , row_number () over (order by a_id, b_id) as r_num from t union all select b_id as id , 'B' as col , row_number () over (order by a_id, b_id) as r_num from t ) , grouped_data as ( select id , min (col) keep (dense_rank first order by r_num) as first_col , min (r_num) as first_r_num , row_number () over ( partition by min (col) keep (dense_rank first order by r_num) order by min (r_num) ) as out_num from union_data group by id ) select a.id as a_id , b.id as b_id from grouped_data a join grouped_data b on a.out_num = b.out_num where a.first_col = 'A' and b.first_col = 'B' order by a.out_num / A_ID B_ID ---------- ---------- 1 5 2 10 4 15 3 rows selected.
I expect him back at the last row too much (like my request).
In addition to change line 5 - 6 5-25 mess up completely:A_ID B_ID ---------- ---------- 1 5 2 10 4 15 6 25
-
query to retrieve the second highest salary managers
Select * from employee where salary = (select max (salary) in e employees where employee_id = e.manager_id and salary < (select max (salary) in employees))
/
It does not run... can someone suggest a new987184 wrote:
our teacher was asked to write without y analytical function.dats.1 list of Manager IDs:
select manager_id from hr.employees where manager_id is not null /
2 manager info:
select employee_id, first_name, last_name, salary from hr.employees where employee_id in ( select manager_id from hr.employees where manager_id is not null ) /
3. Manager second highest salary
with managers as ( select employee_id, first_name, last_name, salary from hr.employees where employee_id in ( select manager_id from hr.employees where manager_id is not null ) ) select m1.employee_id, m1.first_name, m1.last_name, max(m1.salary) second_highest_salary from managers m1, managers m2 where m1.salary < m2.salary group by m1.employee_id, m1.first_name, m1.last_name having count(distinct m2.salary) = 1 /
And execution:
SQL> select employee_id, 2 first_name, 3 last_name, 4 salary 5 from hr.employees 6 where employee_id in ( 7 select manager_id 8 from hr.employees 9 where manager_id is not null 10 ) 11 order by salary desc 12 / EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY ----------- -------------------- ------------------------- ---------- 100 Steven King 24000 102 Lex De Haan 17000 101 Neena Kochhar 17000 145 John Russell 14000 146 Karen Partners 13500 201 Michael Hartstein 13000 108 Nancy Greenberg 12008 205 Shelley Higgins 12008 147 Alberto Errazuriz 12000 114 Den Raphaely 11000 148 Gerald Cambrault 11000 EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY ----------- -------------------- ------------------------- ---------- 149 Eleni Zlotkey 10500 103 Alexander Hunold 9000 121 Adam Fripp 8200 120 Matthew Weiss 8000 122 Payam Kaufling 7900 123 Shanta Vollman 6500 124 Kevin Mourgos 5800 18 rows selected. SQL> with managers as ( 2 select employee_id, 3 first_name, 4 last_name, 5 salary 6 from hr.employees 7 where employee_id in ( 8 select manager_id 9 from hr.employees 10 where manager_id is not null 11 ) 12 ) 13 select m1.employee_id, 14 m1.first_name, 15 m1.last_name, 16 max(m1.salary) second_highest_salary 17 from managers m1, 18 managers m2 19 where m1.salary < m2.salary 20 group by m1.employee_id, 21 m1.first_name, 22 m1.last_name 23 having count(distinct m2.salary) = 1 24 / EMPLOYEE_ID FIRST_NAME LAST_NAME SECOND_HIGHEST_SALARY ----------- -------------------- ------------------------- --------------------- 101 Neena Kochhar 17000 102 Lex De Haan 17000 SQL>
As you can see, most high salary 24000 is won by the King. Second highest salary is 17000 and is won by two managers: Kochhar and De Haan.
SY.
-
Cannot retrieve the data by binary storage by default for XML 11 g
Oracle 11.2
All,
As someone mentioned in another post, I got I should use binary XMLType CLOB rather than 11g because it is more efficient. When I create the XMLType column as binary I can't retrieve the value of the column, but when I use CLOB I am able to extract data on.
-Create table with XMLTYPE column. Since it is 11.2 storage of the column is automatically binary
CREATE THE TABLE HR. XMLTABLESTORE (key_id VARCHAR2 (10) PRIMARY KEY, xmlloaddate date, xml_column XMLTYPE);
-Insert the XML into the XML column
INSERT INTO HUMAN RESOURCES. VALUES XMLTABLESTORE (HR. XMLSEQUENCE. NEXTVAL, SYSDATE, XMLType (bfilename ('XMLDIRX', 'PROD_20110725_211550427_220b.xml'),
nls_charset_id ('AL32UTF8'))); COMMIT;
-When I do a select I see full XML in the xml_column column
SELECT * FROM HR. XMLTABLESTORE
-When I run the following query I get the following:
SELECT extract (xml_column, ' / / MapItem/@ProductNum') ProductNum OF HR. XMLTABLESTORE
ProductNum
-------------
XMLType
-When I run the following query on the @, I get the following:
SELECT extract (xml_column, ' / / MapItem/ProductNum ') ProductNum OF HR. XMLTABLESTORE
ProductNum
-------------
Null value
When I run the same SELECT query retrieves (xml_column, ' / / MapItem/@ProductNum') ProductNum OF HR. XMLTABLESTORE and the table is created by CLOB, I get out the expected value of the XML file.
How can I get the query to retrieve the data through a binary file?
I appreciate any help in advance.
Thank you
Shawn
Published by: 886184 on Sep 20, 2011 15:42Probably a problem with your client tool.
It works for me:
SQL*Plus: Release 11.2.0.2.0 Beta on Mer. Sept. 21 19:39:55 2011 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta SQL> CREATE TABLE xmltablestore ( 2 key_id VARCHAR2(10) PRIMARY KEY 3 , xmlloaddate DATE 4 , xml_column XMLTYPE 5 ); Table created. SQL> INSERT INTO xmltablestore 2 VALUES ('1', sysdate, XMLType(bfilename('TEST_DIR', 'PROD_20110725_211550427_220b.xml'),nls_charset_id('AL32UTF8'))) 3 ; 1 row created. SQL> commit; Commit complete. SQL> SELECT extract(xml_column, '//MapItem/@ProductNum') ProductNum 2 FROM xmltablestore 3 ; PRODUCTNUM -------------------------------------------------------------------------------- 63481062975 SQL> SELECT extractValue(xml_column, '//MapItem/@ProductNum') ProductNum 2 FROM xmltablestore 3 ; PRODUCTNUM -------------------------------------------------------------------------------- 63481062975 SQL> SELECT xmlcast( 2 xmlquery('/Entries/Category/MapItem/@ProductNum' 3 passing t.xml_column 4 returning content 5 ) 6 as number 7 ) ProductNum 8 FROM xmltablestore t 9 ; PRODUCTNUM ---------- 6,3481E+10 SQL> SELECT xmlcast( 2 xmlquery('/Entries/Category/MapItem/@ProductNum' 3 passing t.xml_column 4 returning content 5 ) 6 as varchar2(30) 7 ) ProductNum 8 FROM xmltablestore t 9 ; PRODUCTNUM ------------------------------ 63481062975
BTW, extract and extractvalue functions are deprecated in version 11.2.
Oracle now recommends using XMLCast/XMLQuery. -
SQL query to represent the data in the graph bar
Hello
JDev 11.1.1.5.0
We must create a dashboard to track the translation. We have created the ADF table with buttons 'Create', 'Update' and 'Delete' to manipulate the table.
Our DB table structure is
File_id (PK), File_Name, ToSpanish - ARE (YES/NO), beginning of the ToSpanish, ToChina(YES/No), ToChina-Date... etc.
Once the translated file required language then user must update the DB table using the button "Update".
So far, we have implemented the requirement above.
We need represent the status of the translation in the graph bar with the language as X access and file count get access Ex: Spanish-100 China - 200 files files
Please suggest the sql query to retrieve the necessary info from the DB table that can be represented in the graph bar. Also, it would be great, if you can provide a pointers to create a bar chart.
Thanks in advance,
MSR.
If you set your major increment and minor than 1, then you won't not show decimal points. You can try setting these 10 or 100 to reach your goal.
Subtype = "BAR_VERT_CLUST" >
-
Need to retrieve the records whose salary is higher than the max of avg salar
I wrote a query to retrieve the data whose salary exceeds the maximum salary of the avg of all departments
I would like to write that this query using the associates.SELECT * FROM EMP WHERE SAL> (SELECT MAX(AVG (SAL)) FROM EMP GROUP BY DEPTNO)
I tried
It gives me error that we cannot use a function nested in the collateral.SELECT EMPNO,ENAME,SAL FROM EMP E1 WHERE SAL > ANY( SELECT MAX(AVG(SAL)) FROM EMP E2 WHERE E1.DEPTNO = E2.DEPTNO)
What is the solution of the present?
ThnksThis?
select * from emp a where exists (select 1 from emp b where a.deptno=b.deptno and a.sal>(select round(max(avg(sal))) from emp group by deptno));
-
Error when retrieving the value of the pair name / value
Hi gentlemen,
I am facing a problem while retrieving the value of the pair name / value in the incoming XML file. I am using an Xpath query to retrieve the value but Jdeveloper gives me
an invalid expression error.
Please find below the new xml and xquery.
< ebo:QueryItemListEBM xmlns:ebo = "http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/Item/V2" >
< ebo:DataArea xmlns:aia = "http://www.oracle.com/XSL/Transform/java/oracle.apps.aia.core.xpath.AIAFunctions" xmlns:coreitem = "http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/Item/V2" >
< ebo:Query >
< ebo:QueryCode > QUERY_ITEMS < / ebo:QueryCode >
< corecom:QueryCriteria xmlns:corecom = "http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2" >
< corecom:QueryExpression >
< corecom:ValueExpression >
< corecom:ElementPath > ItemEBO/Item/InventoryLocation/BusinessComponentID < / corecom:ElementPath >
< corecom: Value > 82 < / corecom: Value >
< / corecom:ValueExpression >
< corecom:ValueExpression >
< corecom:ElementPath > ItemEBO/Item/ItemIdentification/ContextID@OPERATING_UNIT_ID < / corecom:ElementPath >
< corecom: Value / >
< / corecom:ValueExpression >
< corecom:ValueExpression >
< corecom:ElementPath > ItemEBO/Identification/BusinessComponentID < / corecom:ElementPath >
< corecom: Value > ba55de86-d8b4-4db1-b599-5aef8424ac3b < / corecom: Value >
< / corecom:ValueExpression >
< corecom:ValueExpression >
< corecom:ElementPath > ItemEBO/Item/ItemIdentification/ContextID@STRUCTURE_NAME < / corecom:ElementPath >
< corecom: Value > PIM_PBOM_S < / corecom: Value >
< / corecom:ValueExpression >
< corecom:ValueExpression >
< corecom:ElementPath > ItemEBO/Identification/review < / corecom:ElementPath >
< corecom: Value > 208281 < / corecom: Value >
< / corecom:ValueExpression >
< / corecom:QueryExpression >
< / corecom:QueryCriteria >
< / ebo:Query >
< / ebo:DataArea >
< / ebo:QueryItemListEBM >
I need to retrieve the value 'ba55de86-d8b4-4db1-b599-5aef8424ac3b' on top of xml and xpath expression that I used is:
bpws:.
Please help with your valuable contributions.
Thank you and best regards,
Vikas marzouk829347 wrote:
Hi Vlad,It works quite well. A big thank you to you.
see you soon,
VikasHi Vikas, could you marking my answer as correct then?
Thank you
Vlad -
Determine the end of the month and then run the script
Hi all
OK, I'm stumped. I can get all kinds of data to date... but I did not find a way (or the same example script) that shows how to retrieve the end of the month.
Why?
I have a master script that runs as a scheduled task. It runs every day and call other scripts based on the date. It is great for things like weekly reports that I just used $dow = {get-date}. DayofWeek but I need to run scripts at the end of the month.I can something together that gets the day, and then performs a logical ugly pop-based < or > but I don't know there's a smoother way to do.
As always, any help greatly appreciated.
See you soon
Hello, medalklector-
One way to do it, it is described by RMToups, Jr. at http://activelydirect.blogspot.com/2011/01/determine-last-day-of-month-in.html. You should be able to set the output to fit your needs. How does do for you?
-
SQL query to retrieve a single record for each employee of the following table?
Hi all
Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.
CREATE TABLE xxc_contact)
empnum NUMBER,
alternatecontact VARCHAR2 (100),
relationship VARCHAR2 (10),
phtype VARCHAR2 (10),
Phone NUMBER
);
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)
expected result:
EmpNum AlternateContact Relationship PhType Phone
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Thanks in advance.
994122 wrote:
Thank you all, that I got a result
http://www.orafaq.com/Forum/m/620305/#msg_620305
By Lalit Kumar B...
Specifically, the two simple solutions provided were:
1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).
SQL > column alternatecontact format A20;
SQL >
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))
3 FROM xxc_contact one)
4. WHEN r = 1
/
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)
3 WHERE phone = rn
4.
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Kind regards
Lalit
Maybe you are looking for
-
How can I determine what profile Firefox 5 is currently using?
How can I determine what profile Firefox 5 is currently using?
-
Pavilion b 14, 015 dx: hp pavillion b 14, 015 dx replacement screen
where can I get this screen also called n140bge-l42 rev.c1 Shimei, HP demand huge sum where else can I source it in USA or INDIAavillion
-
WiFi connected but no internet access
Good so far, didn't have any problem with internet on my mac mini. It connects to my ADSL hotspot and mobile phone, but I can't access the internet or browse. In Network Diagnostics it says "internet - failed" and "Server - failed". These connections
-
Problem with DVD/CD player
Hi I have a HP Pavillion computer p6604f with the Engraver DVD SuperMulti with LightScribe drive technology and it will not work. It will not be displayed under my count and when I go to Device Manager it says "Windows cannot start this hardware dev
-
I can install another type of ram on my laptop
I have a HP Pavilion dv7-1264nr laptop and I would like to improve my ram and would like to know if I have to use DDR2 ram or can I use something different like DDR3.