SQL query - help with join
Dear friends,
Version of DB - 11.1.0.7... , I'm stuck with SQL basics today... need your help...
The slot SQL tells me "cache them locks library" in the database that I will put up as a proactive measure.
I'll be it works via shell script and include the table gv instance_name $ instance ... I'm a little confused as to how a 3rd table "gv$ instance ' can be introduced into the query in order to make the instance_name in the result set...
SELECT * FROM)
SELECT / * + LEADING (a) USE_HASH (u) * /.
instance_name, INST_ID select, blocking_inst_id, blocking_session, username, session_id, sql_id, current_obj #,.
DECODE (sql_opcode, 1, 'CREATE TABLE', 2, 'INSERT') as "order."
Event, mod(P1,16) p1, p2, p3
COUNT (*) totalseconds
, SUM (CASE WHEN wait_class = 'Application' THEN 1 ELSE 0 END) 'Application '.
Of
(SELECT
a.*
, TO_CHAR (CASE WHEN session_state = 'WAITING' THEN ELSE null END p1, '0XXXXXXXXXXXXXXX') p1hex
, TO_CHAR (CASE WHEN session_state = "PENDING" THEN p2 ELSE null END, '0XXXXXXXXXXXXXXX') p2hex
, TO_CHAR (CASE WHEN session_state = "PENDING" THEN ELSE null END p3, '0XXXXXXXXXXXXXXX') p3hex
SGS $ active_session_history one) a
u dba_users
WHERE
a.user_id = u.user_id
AND sample_time BETWEEN sysdate-90 /(24*60) AND sysdate
- AND a test of ('library cache lock', 'library cache pin")
AND event like '% library '.
GROUP BY
INST_ID select, blocking_inst_id, blocking_session, username, session_id, sql_id, current_obj #,.
DECODE (sql_opcode, 1, 'CREATE TABLE', 'INSERT', 2),
event, mod (p1, 16), p2, p3
Having count (*) > 5
ORDER BY
TotalSeconds DESC
, INST_ID select, blocking_session, username, session_id, sql_id, current_obj #, 'Order', event
)
WHERE
ROWNUM < = 20
/
replace
instance_name
by
(select instance_name gv$ instance where INST_ID select = a.inst_id) instance_name
or select... in... a, u, gv$ instance where... and gv$ instance.inst_id (+) = a.inst_id...
Tags: Database
Similar Questions
-
I'm just having a bit of troubel get a correct join query - I thought it was an Inner Join, but I don't get the results I expect.
My table structure is:
Table: lodges
LodgeID (PK)
Lodge
etc.
Table: implemented application
NominationID (PK)
Category
LodgeID
Year
So I try to use this structure to replicate this page:
http://www.safariawards.com/nominees12/
That is to say a list of boxes for each category, they are appointed on.
The query I've tried looks like this:
SELECT appointments. LodgeID, lodges. Lodge, applications. NominationID, applications. Lodges INNER JOIN applications category IT lodges. LodgeID = nominated. NominationID WHERE category = "Best property of Safari in southern Africa" ORDER BY Lodge
But this product:
http://www.safariawards.com/nominees12/southernafrica.php
Its the right number of results, but not the list on the right of the boxes - for example British Airwways is not LodgeID 786
If anyone could help with the SQL right for what would be well appreciated.
That you join on the wrong column. Try this:
SELECT appointments. LodgeID, lodges. Lodge, applications. NominationID, applications. Lodges INNER JOIN applications category IT lodges. LodgeID = nominated. LodgeID WHERE category = "Best property of Safari in southern Africa" ORDER BY Lodge
-
I have two DEVICE and CONTACT tables. The tables are joined for CONTACT_ID DEVICE_ID. I want to print device_ID and the corresponding coordinates on the lower contact. PRIORITY.
How to print a single record with the CONTACT the lowest. PRIORITY?SQL> describe DEVICE; DEVICE_ID NOT NULL VARCHAR2(50) SQL> describe CONTACT; CONTACT_ID NOT NULL VARCHAR2(50) CONTACT_TYPE NOT NULL VARCHAR2(4) PRIORITY NOT NULL DOUBLE PRECISION LASTNAME NOT NULL VARCHAR2(30) FIRSTNAME NOT NULL VARCHAR2(80) SQL> SELECT a.DEVICE_ID, b.LASTNAME,b.PRIORITY from DEVICE a, CONTACT b where a.DEVICE_ID = 'DEVICEA' and a.DEVICE_ID=b.CONTACT_ID(+); DEVICE_ID LASTNAME FIRSTNAME PRIORITY CONTACT_TYPE ---------------------- ----------- --------- -------- ------------ DEVICEA CONTACT1 GN 1 ROUT DEVICEA CONTACT2 Hans 2 ROUT
Thank you
Ravirmalghan wrote:
Thank you Frank, Sundar and Sean. I had less than 3 to work. Two questions. My table of DEVICES has 31936 records.
1. the first one returned 30207, 31936 records 2nd and 3rd a 30348. Since the 2nd result resembles what I expected, the 1st and 3rd one seem to miss some records. For troubleshooting, I tried to limit the query to a few devices, but do not understand why the difference. Any suggestions?The 2nd query not check for type_contact = 'ROUT', it is not surprising that it returns more rows.
The request of 3rd fact actually an inner join. The "WHERE c.rnum = 1" condition is applied after the join, so he rejects all rows that have been added due to the outer join (which is where all the columns of c are NULL). You probably meant to say:LEFT OUTER JOIN got_rnum c ON d.DEVICE_ID = c.CONTACT_ID AND c.rnum = 1;
without a WHERE clause.
2. are there advantages in terms of efficiency. 2nd one does not seem to run faster, so I think it's the best. Any comments?
SELECT a.DEVICE_ID, b.LASTNAME,b.FIRSTNAME,b.PRIORITY FROM DEVICE a, CONTACT b where a.DEVICE_ID=b.CONTACT_ID(+) and b.CONTACT_TYPE = 'ROUT' and b.PRIORITY = (select min(b1.PRIORITY ) from CONTACT b1 where b1.CONTACT_ID = b.CONTACT_ID); 30207 rows selected (10.12 seconds) SELECT DEVICE_ID, LASTNAME, PRIORITY FROM ( SELECT a.DEVICE_ID, b.LASTNAME, b.PRIORITY, ROW_NUMBER() OVER (PARTITION BY a.DEVICE_ID ORDER BY b.PRIORITY) row_num from DEVICE a, CONTACT b where a.DEVICE_ID=b.CONTACT_ID(+)) WHERE row_num = 1; 31936 rows selected (6.68 seconds) WITH got_rnum AS ( SELECT LASTNAME, FIRSTNAME, PRIORITY, CONTACT_TYPE, CONTACT_ID, ROW_NUMBER () OVER ( PARTITION BY CONTACT_ID ORDER BY priority) AS rnum FROM contact where CONTACT_TYPE = 'ROUT' ) SELECT d.DEVICE_ID, c.LASTNAME, c.FIRSTNAME, c.PRIORITY FROM device d JOIN got_rnum c ON d.DEVICE_ID = c.CONTACT_ID(+) WHERE c.rnum = 1; 30348 rows selected (9.07 seconds)
This calendar is not very accurate. One that you run first is likely to be slower, because the data are less likely to be stored in the memory cache.
The 2nd query has only 3 columns in the result set. Which probably doesn't change the speed a lot, but you should fix it anyway.
-
Hi allAny new on Oracle Sql and I need expert input to solve a problem I have to join Oracle.
Have a requirement as below, my reading of request as below.
SELECT A.GCI, B.LOB_IND, B.CED_ID, C. LOB_DESCR OF CUSTOMER, CUSTOMER b, C from LOB
WHERE A.PRIMARY_CED = B.CED_ID (+)
AND B.LOB = C.LOB_DESCR (+)
AND B.LOB_IND (+) = 'Y '.
AND A.GCI IN
(
'339492963',
'339850821');
Output current:
GCI LOB_IND CED_ID LOB_DESCR
339850821 Y 7905108 banking services for businesses
Null Null null 339492963
Power required:
GCI LOB_IND CED_ID LOB_DESCR
339850821 Y 7905108 banking services for businesses
339492963 7859659 null null
In the table B (CLIENT) for a ced_id there will be several entries.
Select ced_id, LOB_IND from CLIENT b where b.ced_id = '7905108';
ced_id LOB_IND
7905108 IS
7905108 null
7905108 null
Select ced_id, LOB_IND from CLIENT b where b.ced_id = 7859659;
ced_id LOB_IND
7859659 null
7859659 null
so when writing of the main request, I took B.LOB_IND (+) = 'Y' condition, since I added this condition and catches of outer join.
the ced_id for "7859659" is not coming in the query below.
SELECT A.GCI, B.LOB_IND, B.CED_ID, C. LOB_DESCR OF CUSTOMER, CUSTOMER b, C from LOB
WHERE A.PRIMARY_CED = B.CED_ID (+)
AND B.LOB = C.LOB_DESCR (+)
AND B.LOB_IND (+) = 'Y '.
AND A.GCI IN
(
'339492963',
'339850821');
Output current:
GCI LOB_IND CED_ID LOB_DESCR
339850821 Y 7905108 banking services for businesses
Null Null null 339492963
Is it possible that the query can be modified to get the below output with CED_ID for B.LOB_IND-> case of Null.
Power required:
GCI LOB_IND LOB LOB_DESCR
339850821 Y 7905108 banking services for businesses
339492963 7859659
Your entered very necessary.
Thank you
Be great if someone could have provide some suggestions.
Use ANSI joins:
SELECT A.GCI, B.LOB_IND,
B.CED_ID,
C.LOB_DESCR
CUSTOMER A
LEFT JOIN
CLIENT b, C from LOB
ON)
A.GCI IN)
'339492963',
'339850821'
)
AND
A.PRIMARY_CED = B.CED_ID
AND
B.LOB_IND = 'Y '.
)
LEFT JOIN
C LOB
ON)
B.LOB = C.LOB_DESCR
)
/SY.
-
SQL Query help find albums from sale
Hi Experts,
I have the following data and the need to find the book Top sold in each type.
Book Type QTY
20 Help the 3 10 Kitchen 1 5 Navigation 2 30 Help the 4 Please let me how can know we get this simple SQL help?
Thank you
Bharat
Hello
Bharat Hegde wrote:
Hi all
I tried to use Dense_rank as below. But it gives me the top selling books. I need high library in each type...
This looks like a job for 'PARTITION BY type
For example:
WITH got_rnk AS
(
SELECT b.bid, b.type
SUM (o.quantity) AS total_quantity
DENSE_RANK () OVER ( PARTITION BY b.type
ORDER OF SUM (o.quantity) / / DESC
) AS rnk
B BOOK
o order1
WHERE b.bid = o.bid
GROUP BY b.bid, b.type
)
SELECT total_quantity, type submission
OF got_rnk
WHERE rnk = 1
;
. Aggregate functions (such as the SUM, above) are calculated before analytical functions, so an analytic function (such as DENSE_RANK above) may depend on an aggregate function; you don't need a separate subquery for that.
-
SQL Query Help (not working not properly)
Hello everyone,
I use JDeveloper 12.1.2.0.0. I do a two-way communication using 3 tables, with links between them (and using schema HR).
In my example, I have something like:
Departments, employees, and the SalaryByJobs (I created this table where it shows a departmentd id, employee id, salary).
Whenever I click on one OR more departments, the employees up-to-date table by putting on the table, employees who belong to the selected department and the salaryByjob to put the jobs of the employees selected on the employees table.
So it's something like this:
The departments selected-> employees selected-> salarybyjbobs of these employees.
My query used (in the view) has the following code:
SELECT Employees.COMMISSION_PCT,
Employees.DEPARTMENT_ID,
Employees.EMAIL,
Employees.EMPLOYEE_ID,
Employees.FIRST_NAME,
Employees.HIRE_DATE,
Employees.JOB_ID,
Employees.LAST_NAME,
Employees.MANAGER_ID,
Employees.PHONE_NUMBER,
Employees.SALARY
Employees EMPLOYEES
WHERE (department_id IN (select * from THE (select cast (in_list(:variavel3) as mytableType) double) a))
Since I use the links, the employees table does not show anything at the beginning, so I added this to my query used to go: OR nvl(:variavel3,0) = 0
But now, whenever I try to select multiple lines, it gives me the invalid numbers and I don't understand why...
It's only one line of code and it is not in the bean.
Can someone help me?
PS - The bean will Department by Department, adds the departments with ',' and for each Department, gets employees who belongs to them.
My best regards,
Frederico Barracha.
The expression NVL (: variavel3, 0) = 0 is not correct. The data type of the return value of the NVL function is considered to be equal to the data type of the argument of 1 (that is, the data type of the variable binding: variavel3). You said that this variable contained a list separated by commas to ID, so the data type of the variable is VARCHAR2. As long as you compare the NVL expression of a number, you get 'Invalid number' exception, because Oracle expects a numeric data type on the left side of the comparison operator.
To avoid the exception "Invalid number", you can modify the expression by using one of the following options:
: variavel3 IS NULL
NVL (: variavel3, ' *') = ' *'
NVL (: variavel3, ' 0') = '0'
Option 1, so the simplest and clearest.
Dimitar
-
SQl query help please...
Hello
I have a requirement... can help you pleease
I have a table with two columns called Doc R, Seq R
Sampled data:
Type Doc R Seq R -------- --------- ------------ R R1 Null Q Q1 R1 R R2 Null Q Q2 R2 R R3 Null Q Null Null Now if you see first two records R1 and R2 have corresponding Q2..... if you see R3 dont have Q values.. Now i want the count of R3 like records where it does not have Corresponding Q values in ... any ideas please...
Hello
Another way, which could be more efficient (but less clear):
WITH got_grp AS ( SELECT CASE WHEN rtype = 'Q' THEN seq_r ELSE doc_r END AS grp , CASE WHEN rtype = 'Q' THEN 0 ELSE 1 END AS r_val FROM yourtable WHERE rtype IN ('Q', 'R') ) SELECT COUNT (COUNT (*)) AS grp_cnt FROM got_grp GROUP BY grp HAVING COUNT (*) = SUM (r_val) ;
You have not said if a line where
rtype = 'R' and doc_r has the value NULL is considered to be a match for a line where
rtype = 'Q' and seq_r is NULL.In the application of Cyn, they are not a match.
In the above query, they are.
A query can be changed for a different result. -
Hello, I'm doing a migration of SQL Server T - SQL to oracle 11 g PL/SQL, and I don't want to use a global temporary table; Instead, consider using sliders and pl/sql table.
I got hit in a scenario where I need to convert the following in a single sql statement.
Stage of T - SQL:
============
Insert (#ActCde)
InvntrySbLdgrChngeID
DlHdrID
DlDtlID
ChemID
StrtgyID
Quantity
Value
Modified)
Select InvntrySbLdgrChngeID
DlHdrID
DlDtlID
ChildPrdctID
StrtgyID
VolumeChanged
ValueChanged
, 'N'
of InventorySubLedgerChange
where LastInChain = 'Y '.
-updated column "Changed" of particular documents to 'Y' based on conditions
Update #ActCde
Changed the value = 'Y '.
of #ActCde (nolock)
Left Outer Join InventorySubledgerDetail ISD (nolock)
on #ActCde.DlHdrID = DSI. DlDtlChmclDlDtlDlHdrID
and #ActCde.DlDtlID = ISD. DlDtlChmclDlDtlID
and #ActCde.ChemID = DSI. DlDtlChmclChmclChldPrdctID
and #ActCde.StrtgyID = DSI. StrtgyID
and the DSI. AccntngPrdID = @i_AccntngPrdID - variable parameter
Where abs (#ActCde.Qty - isnull (ISD.) BeginningVolume, 0)) >.01
or abs (#ActCde.Value - isnull (ISD.) BeginningValue, 0)) >.01
or (abs(#ActCde.Qty) = 0 and)
ABS(#ActCde.value) = 0 and
ABS (isnull (ISD. BeginningVolume, 0)) = 0 and
ABS (isnull (ISD. BeginningValue, 0)) = 0
)
Convertion of SQL:
===============
I would like to do something like
Select A.InvntrySbLdgrChngeID,
A.DlHdrID,
A.DlDtlID,
A.ChemID,
A.StrtgyID,
A.Qty,
A.Value,
A.Changed
Of
(select InvntrySbLdgrChngeID
DlHdrID
DlDtlID
ChildPrdctID AS ChemID
StrtgyID
VolumeChanged AS Qty,
ValueChanged value have
, 'N'
of InventorySubLedgerChange
where LastInChain = 'Y') A LEFT OUTER JOIN InventorySubledgerDetail B
ON A.DlHdrID = B.DlDtlChmclDlDtlDlHdrID
and A.DlDtlID = B.DlDtlChmclDlDtlID
and A.ChemID = B.DlDtlChmclChmclChldPrdctID
and A.StrtgyID = B.StrtgyID
and B.AccntngPrdID = i_AccntngPrdID - parameter varibale
Where abs (A.Qty - isnull(B.BeginningVolume,0)) >.01
or abs (A.Value - isnull(B.BeginningValue,0)) >.01
or (abs (A.Qty) = 0 and)
ABS (A.value) = 0 and
ABS (IsNull(B.BeginningVolume,0)) = 0 and
ABS (IsNull(B.BeginningValue,0)) = 0
)
And I need to change the 'A.CHANGED' column value 'Y', based on the outer join, as is above T - SQL.
IF this wont work so pls help me to another way to do this.
in this regard, your help is appreciated.
Thank you!
SSTry this
select #ActCde.InvntrySbLdgrChngeID , #ActCde.DlHdrID , #ActCde.DlDtlID , #ActCde.ChildPrdctID , #ActCde.StrtgyID , #ActCde.VolumeChanged , #ActCde.ValueChanged , case when abs(#ActCde.Qty - isnull(ISD.BeginningVolume,0)) > .01 or abs(#ActCde.Value - isnull(ISD.BeginningValue,0)) > .01 or ( abs(#ActCde.Qty) = 0 and abs(#ActCde.Value) = 0 and abs(isnull(ISD.BeginningVolume,0)) = 0 and abs(isnull(ISD.BeginningValue,0)) = 0 ) then 'Y' else 'N' end changed from InventorySubLedgerChange #ActCde Left Outer Join InventorySubledgerDetail ISD (nolock) on #ActCde.DlHdrID = ISD.DlDtlChmclDlDtlDlHdrID and #ActCde.DlDtlID= ISD.DlDtlChmclDlDtlID and #ActCde.ChemID = ISD.DlDtlChmclChmclChldPrdctID and #ActCde.StrtgyID = ISD.StrtgyID and ISD.AccntngPrdID = @i_AccntngPrdID - paramenter variable where LastInChain = "Y"
-
Hello
I have the table and professorid, studentid, classid.
Please provide the sql code to find professor_id which hosts up to students.
with t as)
Select professor_id,
ROW_NUMBER() over (order by count (distinct student_id) desc) rn
from your_table
Professor_id group
)
Select professor_id
t
where rn = 1
/
However, if there is a tie and a teacher number max of students has more meanings will select one of them. If you want that all teachers use:
with t as)
Select professor_id,
DENSE_RANK() over (order by count (distinct student_id) desc) rn
from your_table
Professor_id group
)
Select professor_id
t
where rn = 1
/
SY.
-
SQL monitor help with column of chronology
In the report attached to sql, in the timeline column means the whole last 3 began simultaneously and hash join is the first exploited who started?
my understanding is 'index range scan' should start first and give the data to "Single Partition range". Only once this step completed, he should 'TABLE ACCESS Full'. Isn't this correct?
Thanks for your time!
Your description is correct - and I think that you just have to allow some defects in the rounded, graphic display of errors and inconsistencies in what is "the order of execution.
If it is still possible, you can watch dbms_sqltune.report_sql_monitor output text () as numbers COULD clarify the sequence - on the other hand, the granularity of the timer is not very fine.
You may find that the chronology of hash join begins before the access times two table - which highlights the problem of "means to launch an operation." The subroutine "do a hash join" must begin before the two tablescans, on the other hand the mechanism 'return rowsource to parent' cannot start until after the second table access began to return the hash join lines.
Another sign of the available seeds, of course, is that the select statement does not seem to have started until a few seconds after the hash join has started!
Concerning
Jonathan Lewis
-
SQL query help needed in the Clause type
Hello
I'm currently learning Clause type. How can I write in the clause type to get the result below:
I have a table like this
DEPTNO ENAME
------- ------
20 SMITH
CELINE 10
BOND 20
ALLEN 30
WARD 30
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
SCOTT 20
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
I want the output should look like this
DEPTNO ENAME
------ -----
CELINE 10, CLARK, KING, MILLER
20 JONES, ADAMS, BOND, FORD, SCOTT, SMITH
30 MARTIN, JAMES BLAKE, WARD, TURNER, ALLEN
Hear is the script I am currently working on.
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
A1
of emp_group
model
ignore the nav
partition (deptno)
dimension (ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename DESC) rn)
measures (ename, LPAD(' ', 100) A1)
rules)
A1 [rn > 0] = ename [cv ()],
A1 [0] = ename [cv ()]
)
order by deptno
;
your help is very appreciated.
Thank you in advance.
Try this.
Select
*
Of
(
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
names
rn
of emp_group
model
ignore the nav
partition (deptno)
dimension of)
ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename) rn
)
measures (ename, cast (null as names of varchar2 (40)))
rules
(
names [any] order by desc = ename [cv ()] rn | «, » || names [cv () + 1]
)
order by deptno
)
where rn = 1
Best regards, Andrei
-
with t as
(
Select to_date (January 1, 2014 "," dd-mon-yyyy ') col1, 'a' col2, col3 1.04 by union double all the
Select to_date (5 January 2014 ',' mon-dd-yyyy "") col1, 'a' col2, col3 1.02 Union double all the
Select to_date (8 January 2014 ',' mon-dd-yyyy "") col1, col2, col3 1.01 Union ' b' double all the
Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2, col3 1.05 Union ' b' double all the
Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2, col3 2.00 Union ' b' double all the
Select to_date (January 10, 2014 "," dd-mon-yyyy "") col1, col2 'c', col3 3.05 Union double all the
Select to_date (January 14, 2014 "," dd-mon-yyyy "") col1, col2, col3 6.00 Union ' b' double all the
Select to_date (15 January 2014 "," dd-mon-yyyy "") col1, col2, col3 6.10 Union ' b' double all the
Select to_date (15 January 2014 "," dd-mon-yyyy ') col1, col2, col3 6.05 of the double ' c'
)
Select t.*
t;
OUTPUT:
COL1 COL2 COL3
01/01/2014 by 1.04
05/01/2014 a 1.02
08/01/2014 b 1.01
10/01/2014 b 1.05
10/01/2014 b 2
10/01/2014 c 3.05
14/01/2014 b 6
15/01/2014 b 6.1
15/01/2014 c 6.5
Required power must be:
COL1 COL2 COL3
01/01/2014 by 1.04
05/01/2014 a 1.02
08/01/2014 b 1.01
10/01/2014 b 1.01
10/01/2014 b 1.01
10/01/2014 c 1.01
14/01/2014 b 6
15/01/2014 b 6
15/01/2014 c 6
If we found the dates duplicate, we need update COL3 value with the previous value of max (date) value COL3.
Please save my life!
Hello
Try this:
WITH
t AS
(SELECT to_date (January 1, 2014 "," dd-mon-yyyy ') col1, 'a' col2, 1.04 col3 FROM dual)
UNION ALL
SELECT to_date (5 January 2014 ',' mon-dd-yyyy "") col1, 'a' col2, 1.02 col3 FROM dual
UNION ALL
SELECT to_date (8 January 2014 ',' mon-dd-yyyy "") col1, col2 'b', 1.01 col3 FROM dual
UNION ALL
SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 1.05 col3 FROM dual
UNION ALL
SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 2,00 col3 FROM dual
UNION ALL
SELECT to_date (January 10, 2014 ',' mon-dd-yyyy "") col1, col2 'c', 3.05 col3 FROM dual
UNION ALL
SELECT to_date (January 14, 2014 ',' mon-dd-yyyy "") col1, col2 'b', 6.00 col3 FROM dual
UNION ALL
SELECT to_date (15 January 2014 ',' mon-dd-yyyy "") col1, col2 'b', 6,10 col3 FROM dual
UNION ALL
SELECT to_date (15 January 2014 ',' mon-dd-yyyy "") col1, col2 'c', 6.05 col3 FROM dual
)
a, as
(
SELECT
col1
col2
col3
count (col1) on count_col1 (col1 partition)Of
t
)Select
a.Col1
a.col2
a.col3
case when a.count_col1 = 1
then a.col3
Max (t.col3) else keep (dense_rank of the first order by t.col1 desc)
end new_col3Of
one
left join (t.col1 t<>Group
a.Col1
a.col2
a.col3
a.count_col1
order by
a.Col1;
COL1 COL2 COL3 NEW_COL3
--------- ---- ---- --------
1 January 14 a 1.04 1.04
5 January 14 a 1.02 1.02
January 8, 14 b 1.01 1.01
January 10, 14 b 1.05 1.01
January 10, 14 2 b 1.01
10 January 14 c 3.05 1.01
January 14, 14 b 6 of 6
15 January 14 b 6.1 6
15 January 14 c 6.05 69 selected lines
Kind regards
Peter
-
I have a problem with the join, I try to use it to eliminate the mass number of path layers and sublayers I. Everything is already connected by anchor point but they have all of the separate layers and it is heavy for shipping and export.
Here's what I want to join, lines are in place and, even once, the anchor points are connected. I want to keep this form:
And that's what he keeps to:
Any suggestion is welcome.
dmuir,
You can reach only two segments of track at the same time, so that each (no end) Anchor Point has only two adjacent segments.
You can combine paths and creating paths compound and other things, but you're stuck with a number of roads as building blocks.
-
SQL query date with century / year
We have a database of oracle with about 6 million documents. There is a date field called Date entered from 1985 to the present day.
Most of these recordings was entered into before January 1, 2000.
If I run a query like
Select count (*) (TableName) where entered_date < 1 January 00 ' I get 0
If I do
Select count (*) (TableName) where entered_date < 31 December 99 ' I get 0
BUT IF I DO
Select count (*) (TableName) where entered_date < 1 January 00 ' get 6 million documents
or
Select count (*) in the TREASURY.ctrc where entrydate > 31 December 99 ' get 6 million documents
I tried the same queries using 4 digit years but get the same results. He thinks that 2000 is at least 1999
How to do this?
Thank youHello
975204 wrote:
There are 6 million documents on the table
about two-thirds have a date prior to 1 January 2000How do you know this? Knowledge of the application, you can find out that two-thirds of them are supposed to have dates from before 2000, but if
SELECT COUNT (*) FROM TABLE_NAME WHERE ENTRYDATE < TO_DATE ( '01-JAN-2000' , 'DD-MON-YYYY' ) ;
Returns the value 0, which has strong enough evidence that none of them actually do.
When I look at the dates, they appear as December 31, 86
Another example of why use 2 digit years is a bad idea.
I can't actually provide these confidential customer data dump
Seriously; You can provide an output DUMP? You already said that it displays as December 31, 86, so even if the fact that 1 entry in the table of the line 6 million was made on December 31, 1986 was such a big secret, he is already out, and you don't cause any harm more by showing the results of DUMP.
I ran the query with the same format as the date, that is to say
SELECT COUNT (*) FROM THE DEPARTMENT OF FINANCE. CRTC WHERE ENTRYDATE< to_date="" (="">
"DD-MON-YY."
)but same results
If the column is defined as a DATE type, Oracle made a distinction based on the way the data is displayed, which means that she think that December 31, 86 is different from December 31, 1986?No, all the DATE columns have the same format. A DATE can be displayed in one way of the other, but it is stored in the form of or.
Should I convert all the data from one year to 4 digits?
A 4-digit year dates should be always displayed.
Run an update query that said if year > = 80 and<= 99="" add="" 19="" in="" front="" of="" the="" year,="" else="" add="" 20="" in="" front="" of="" the="">=>
We will find out exactly what the problem is, first of all.
Have you seen the Ascheffer message? ^ 1 ^ it was dated just a couple of minutes before your last post, so you might not notice. Run it to see what are the years of 4 real numbers.
If it shows, for example, there are a lot of entrydates in the years 2080 to 2099, and if you decide that all who should really be 100 years earlier, use ADD_MONTHS to remedy:UPDATE table_name SET entrydate = ADD_MONTHS ( entrydate , -100 * 12 ) WHERE entrydate >= TO_DATE ( '01-JAN-2080' , 'DD-MON-YYYY' ) AND entrydate < TO_DATE ( '01-JAN-2100' , 'DD-MON-YYYY' ) ;
Published by: Frank Kulash, 15 March 2013 18:09
^ 1 ^ you see of course, message Ascheffer; I was still typing the message above when you posted another.
-
SQL query help (we connect by clause level)
Hi all
I have this application developed with data with the clause.
Output current: -.With dat As ( select '@AAA @SSS @DDD' col1 from dual union all select '@ZZZ @XXX @TTT @RRR @ZZA' col1 from dual ) Select regexp_substr( col1 , '[^@][A-Z]+',1,level) Show from dat connect by level <= regexp_count(col1, '@');
1st row comes very well, but the next line data copy. And the number of total records = 30. I tried with some, but not worked.SHOW ----------------------- AAA SSS DDD RRR ZZA TTT RRR ZZA XXX DDD RRR SHOW ----------------------- ZZA TTT RRR ZZA . . . . . .
Expected results: -.
I need some changes on my request and I am not able to see that. So anyone can add to that or can also provide a different solution also.SHOW ----------------------- AAA SSS DDD ZZZ XXX TTT RRR ZZA
Thank you!
AshutoshThanks for providing the loan to the use of query. :)
Here's a solution :-(tested on 10 g, do not have 11 g at hand)
For 11g, just use regexp_count instead of functions of the length.
With dat As ( select '@AAA @SSS @DDD' col from dual union all select '@ZZZ @XXX @TTT @RRR @ZZA' col1 from dual ) Select regexp_substr( col, '[^@][A-Z]+',1,level) Show from dat connect by nocycle level <= length(col) - length(translate(col, 'A@', 'A')) and col = prior col and prior sys_guid() is not null; SHOW ------------------------ AAA SSS DDD ZZZ XXX TTT RRR ZZA 8 rows selected
Maybe you are looking for
-
Pavilion x 360: tour of laptop computer during the upgrade to Windows 10 stuck on the hp logo
I was upgrading the laptop for Windows 10 and after that it restarted, it got stuck on the logo of hp for about 30 min. I turned it off about 3 times and it is still stuck on the hp logo.
-
Windows 7 recovery disk will not work!
OK, so I have a laptop Compaq Presario CQ61 with windows 7 64-bit, and it crashed a few weeks ago. I was told to fix it I would need to order the recovery of best2serve discs so I did and they arrived yesterday. Although earlier, I tried to grab the
-
HP ENVY 15-j154ca: problem with Windows BlueTooth HP ENVY 15-j154ca 10-64 bit
Hi, need your kind help to solve the problem of bluetooth in my hp envy 15-j154ca running 64-bit Windows 10. I have no category of BT in Device Manager. Sometimes this is after a microsoft update, but right after another update, the BT category under
-
vCenter Plugin - host and iDRAC on separate networks - Options?
Hi all We have 2 x R720 of virtual hosts with LOM IPs on the LAN (10.227.0.x) and runs in dedicated mode NIC iDRAC IPs on a physically separate management network - iDRAC. 10.227.2.x and is accessible from the management network. Dell vCenter Managem
-
my vista can't do anything after update yesterday (February 10)
Yesterday my laptop (toshiba satellite a135-s4467) update of msn and when my com want to restart .and my com... on screen displays.. .Configuring updated 1-3-... % complete step I wait display see the.. ' Configuration updated step 3-3 - 100% complet