Oracle

SQL - How to select a row having a column with max value in Oracle

♀尐吖头ヾ 提交于 2021-01-28 12:40:40
问题 date value 18/5/2010 40 18/5/2010 20 20/5/2010 60 18/5/2010 30 17/5/2010 10 16/5/2010 40 18/5/2010 60 18/5/2010 25 Output date value 18/5/2010 60 20/5/2010 60 I need to query for the row having max(value)(i.e. 60). So, here we get two rows. the date can be in any order Plz do not use rownum and subquery I need a dynamic query 回答1: I believe this is what you're looking for: select * from table where value = (select max(value) from table); 回答2: select * from (select * from table order by value

Sqoop import job error org.kitesdk.data.ValidationException for Oracle

拜拜、爱过 提交于 2021-01-28 12:38:40
问题 Sqoop import job for Oracle 11g fails with error ERROR sqoop.Sqoop: Got exception running Sqoop: org.kitesdk.data.ValidationException: Dataset name 81fdfb8245ab4898a719d4dda39e23f9_C46010.HISTCONTACT is not alphanumeric (plus '_') here's the complete command: $ sqoop job --create ingest_amsp_histcontact -- import --connect "jdbc:oracle:thin:@<IP>:<PORT>/<SID>" --username "c46010" -P --table C46010.HISTCONTACT --check-column ITEM_SEQ --target-dir /tmp/junk/amsp.histcontact -as-parquetfile -m 1

Adding a new column to an existing table in production

时光怂恿深爱的人放手 提交于 2021-01-28 12:31:58
问题 What is the best approach to add a not null column with default value in production oracle database when that table contain one million records and it is live. Does it create any locks if we do the column creation , adding default value and making it as not null in a single statement? 回答1: Depends on the version. Starting from 11g, you can execute a simple ALTER TABLE command and there will be no impact, the default value is not materialized and taken from dictionary information. alter table

ORA-00913: too many values while using case when

不羁的心 提交于 2021-01-28 12:09:23
问题 I have a requirement such that, if one condition is true i should execute on query Q1 if that condition fails, i should execute another query Q2. This queries result is the records of search performed by the user. I am using case when statement for if condition, as Q1 and Q2 have more than one column to retrieve, I am getting ORA-00913: too many values . I came to know that case when cannot execute queries with more columns in retrieving data. Can anyone suggest how to achieve this type

getting proper date format from SQL search results (datetime.datetime)

烂漫一生 提交于 2021-01-28 11:57:34
问题 This is my first time using cx_oracle. Part of my project is to create a search engine that processes "SELECT FROM.." queries and displays them. This is for searching patient information and the tests he/she have been prescribed. I thought it would also be a good idea to return prescribe dates for tests. Here is what I execute: searchPatientName = "SELECT b.PATIENT_NO, a.NAME, c.TEST_NAME, b.TEST_DATE, b.RESULT FROM patient a, test_record b, test_type c WHERE b.TYPE_ID = c.TYPE_ID AND b

sorting data in oracle

纵然是瞬间 提交于 2021-01-28 11:47:01
问题 I have a tricky scenario. Data in the table is as follows CustomerId Transaction Type Transaction Amount 1 Payment 100 1 payment 200 1 ReversePayment -100 1 ReversePayment -200 I have transnational table with transaction types being "Payment", "ReversePayment". There are multiple records for a customer with some records being Payment and some being ReversePayment. Is there a way to sort data as follows CustomerId Transaction Type Transaction Amount 1 Payment 100 1 ReversePayment -100 1

Hibernate constraint already exists

会有一股神秘感。 提交于 2021-01-28 11:43:13
问题 i need help to solve this hibernate bug so every time i put a map annotation in my entity i got this error,It tries to recreate some existing constraints. @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "ID_PAYS") public PrmPays getPrmPays() { return this.prmPays; } public void setPrmPays(PrmPays prmPays) { this.prmPays = prmPays; } And this is the error ! alter table ref_entite add constraint FK4xutpn4uffubj8bfw92mmk30f foreign key (id_pays) references prm_pays Caused by: java.sql

Deleting records from one table joined onto another table SQL

谁说我不能喝 提交于 2021-01-28 11:33:10
问题 I have two tables one with 212,000 records (deprecated records) and the other with 10,500,000 records I would like to join the two tables on id and version_number fields as both tables have these fields. I was hoping that from the joined table that the matched records (from the joined tables) could be deleted i.e all of the 212,000 records get deleted from the 10,500,000 I was wondering what the best approach would be for this using Oracle SQL? I have seen example where inner join has been

How to read Oracle Spatial data with rgdal (missing drive?)

淺唱寂寞╮ 提交于 2021-01-28 11:31:20
问题 I would like to read spatial data into R from my Oracle Spatial database. When I execute ogrDrivers() I do not see anything for Oracle Spatial. And the following fails: > require(rgdal) > ogrInfo(dsn="OCI:myusr/mypwd@mydb:MYTABLE:") Error in ogrListLayers(dsn = dsn) : Cannot open data source It looks like Oracle Spatial driver is not normally built into OGR (Oracle makes it really difficult for everybody to work and interoperate with other eco-systems!). I am wondering whether there are other

Calculating passed service hours for open tickets (Oracle SQL)

孤人 提交于 2021-01-28 11:27:46
问题 I'm trying to calculate the time that has passed since a service request has been logged (service time), based on service hours. Start time is the time the ticket has been logged (date_logged), end time would be either the current time for open tickets or the date_closed for closed tickets. Service hours are: Monday to Thursday 07:00 - 16:30 Friday 07:00 - 13:00 So it should look something like this (minus the "current datetime" column, that's just for context): Ticket-Nr. date_logged service