oracle11g

Analytic function and select specific row

独自空忆成欢 提交于 2019-12-08 11:26:06
问题 I have a table Tdate Name value 20130101 xxx 1.2 20130102 xxx 1.4 ... 20130101 yyy 1.3 20130102 yyy 2.3 I want to calculate the value correlation between each name in Jan 2013, and list top 20 of them. Here is my code: With targetRow as ( Select XXX Where tDate is “20130131”) Select a.name, b.name, corr(a.value,b.value) over (partition by name Range between 31 preceding and targetRow) Correlation From logprofittest a, logprofittest b Order by correlation Here are questions: (1) How to

How to monitor all the executed sql statements as a result of single transaction

徘徊边缘 提交于 2019-12-08 11:24:33
问题 I am in the process of upgrading our server from one version to other.So for this purpose i need the detail of all the queries executing in single transaction. I am enabling trace logs for that but that is a tedious process as it contains system related queries also.AWR reports seems to be not working. I am using oracle 10/11 g.Is there any other way in sql developer to achieve this goal. 回答1: Tracing is the only way to see all statements executed. AWR works by sampling active sessions; this

SQL MIN values from two tables

有些话、适合烂在心里 提交于 2019-12-08 11:04:28
问题 I have below mentioned data. I am looking to get min of Start message and corresponding min of success message. If there is no start or success message present then it should show null. Start Message Table ID1 Timestamp_start_msg_recieved date jobid message time in seconds 1234 5/14/2014 10:02:29 5/14/2014 abc start 262 1234 5/14/2014 10:02:31 5/14/2014 abc start 264 1234 5/14/2014 10:02:45 5/14/2014 abc start 278 1234 5/14/2014 10:02:50 5/14/2014 abc start 285 1234 5/14/2014 10:09:04 5/14

ORA-01427: single-row subquery returns more than one row

别来无恙 提交于 2019-12-08 10:20:07
问题 my query is as follows: SELECT DISTINCT * FROM (SELECT depts."ID", depts.arabic_description FROM sng_v_org_unit_departments depts INNER JOIN (SELECT "ID", arabic_description, ouh_id FROM sng_v_org_unit_headers START WITH "ID" = (SELECT headid FROM emppirmesion per inner join empldabdetail empinfo on per.emprecid = empinfo.recid where lower(empinfo.shortname) = lower('ibmadmin') and per.headid > 0 and per.clasisymbolicname = 'SoHiring') CONNECT BY PRIOR "ID" = ouh_id) heads ON depts.ouh_id =

(hibernate4) org.hibernate.MappingException: Unknown entity

冷暖自知 提交于 2019-12-08 10:02:38
问题 I am a newbie to Java EE, please help! The following code used struts2+hibernate4+oracle11g. After I run this code, it gives me this error message: org.hibernate.MappingException: Unknown entity UserDetails.java import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import org.hibernate.service

Get only top row from SQL Query

我的梦境 提交于 2019-12-08 09:45:37
问题 Hello I'm having trouble with getting the Top 1 row using the below query. its in oracle, plsql. SELECT per.person_no, perbus.person_no, perbus.edit_dt, perbus.org_name, perbus.FIRST_NAME FROM users.persons per LEFT OUTER JOIN ( SELECT ASSOC.edit_dt,PER_CONTACTS.PERSON_NO, PER_CONTACTS.PERSON_ID AS PER_ID, PER.EXTERNAL_PERSON_ID AS EXT_PER_ID, PER_CONTACTS.LNAME||', '||PER_CONTACTS.FNAME AS NAME, PER_CONTACTS.FNAME AS FIRST_NAME, PER_CONTACTS.MNAME AS MIDDLE_NAME, PER_CONTACTS.LNAME AS LAST

How to print the result in different line using SQL query?

£可爱£侵袭症+ 提交于 2019-12-08 09:23:32
问题 I am executing the below SQL query which result is displaying as in one line but instead of printing it it one line i want to split into two different line and print the value. SQL Query: select (case when max(PK_MTF1000) = min(PK_MTF1000) and count(PK_MTF1000) = count(*) or max(PK_MTF1000) is null then 'same' else 'diff'end)as PK_MTF1000,max(PK_MTF1000),min(PK_MTF1000) + CHAR(13) , (case when max(MID) = min(MID) and count(MID) = count(*) or max(MID) is null then 'same' else 'diff'end) as MID

Checking if the “system” falls between two dates in SQL

眉间皱痕 提交于 2019-12-08 08:51:01
问题 The Scenarion is DEMO001 system is booked from 10-Aug to 11-Aug by some user. START_DATE END DATE SYSTEM 2016-08-10 2016-08-11 DEMO001 2016-09-05 2016-09-08 DEMO001 2016-08-08 2016-08-11 DEMO013 2016-08-16 2016-08-18 DEMO017 If Other user tries to book this system between these days . We have to check and pass 0 or 1. I will get an input parameter 1) start_date as 2016-08-08 and 2016-08-15. 2) 2016-09-06 and 2016-09-07 3) 2016-08-08 and 2016-08-09 I have to write a PLSQL/SQL code to pass 0

fetch result from the query

耗尽温柔 提交于 2019-12-08 08:47:20
问题 CREATE TABLE TEMP25 ( STATUS VARCHAR2(200 BYTE) ); Insert into TEMP25 (STATUS) Values ('PENDING'); Insert into TEMP25 (STATUS) Values ('ERROR'); Insert into TEMP25 (STATUS) Values ('ERROR'); Insert into TEMP25 (STATUS) Values ('ERROR'); Insert into TEMP25 (STATUS) Values ('NOT_REQUIRED'); Insert into TEMP25 (STATUS) Values ('NOT_REQUIRED'); Insert into TEMP25 (STATUS) Values ('PENDING'); Insert into TEMP25 (STATUS) Values ('PENDING'); Insert into TEMP25 (STATUS) Values ('ERROR'); Insert into

Rails3 cannot save 'ñ' to Oracle 11g

浪子不回头ぞ 提交于 2019-12-08 08:16:19
问题 I'm using Rails 3.2.13, ruby 1.9.3 and Oracle 11g. When saving a record in the DB with a character like 'ñ' I get the error below: ActiveRecord::StatementInvalid (Encoding::UndefinedConversionError: U+00F1 from UTF-8 to US-ASCII: INSERT INTO "OMNIAUTH_USERS" ("CREATED_AT", "FIRST_NAME", "ID", "LAST_NAME", "STATUS", "UID", "UPDATED_AT") VALUES (:a1, :a2, :a3, :a4, :a5, :a6, :a7)): app/controllers/user_sessions_controller.rb:18:in `create' I tried to run this query to see the language used by