I have this query, and i am trying to format all dates for the two columns mentioned in the query below to the format mentioned: and i want to convert the results from timeone and timetwo to another date format DD-MM-YYYY HH:MIPM but when I run the query I got back invalid number. The datatype of the timeone …
Tag: oracle
PL SQL Pivot: use different aggregates
I want to pivot sum(sales) per country as below. But the price column should be an average per shop. So, I would love to have this result: Desired Result: shop avg_price US CN 2 6 100 10 3 5 60 10 Current Result: shop price US CN 2 5 null 5 2 7 100 5 3 5 60 10 I
Oracle SQL: How to fetch only style tag attributes from column?
I want to fetch only style tag attributes from a column i.e., style tag between double quotes (“). Style= can be anywhere in the column. Below is the sample data: Expected: Output: Tried below code: With this I am getting double quotes also in the output. Need help on how to get only style tags without …
Oracle sql query to group two sets of dates if sequencials
I have the next table: EMPLOYEE CODE START_DATE END_DATE 02097368 F7H3 09/07/2018 20/10/2018 02097368 F7H3 21/10/2018 05/01/2019 02097368 F7H3 06/01/2019 12/01/2019 02097368 F7H3 13/01/2019 02/02/…
Oracle SQL: how to concatenate text until reaches maximum size
I have a case: some script to reproduce: And Select: What i want to achieve is concatenate texts until sum of them is less than 3000. If larger, then another text. And here goes problem: texts with group 1 when You sum them is greater than 3000. Text with id = 2 supposed to have group 2 but is 1.
How to evaluate a logical expression in a column in SQL
let’s say I have a database table “ACCOUNTS” where it only has 3 fields: ACCOUNT_NUMBER (BIGINT) CREDIT (BIGINT) DEBIT (BIGINT) And I simply want to make a query that will show only two columns: ACCOUNT_NUMBER (BIGINT) “BALANCED” (A boolean value. True if Credit == Debit, false o…
Substring to Get value only after first occurrence of : in Oracle SQL
I have data in below format in an Oracle table column: I want to have data in below format i.e to have distinct first string after first occurrence of :: I can get the value for first record using below query But I am unable to get it for others if there are more than one : in a column
Convert Timestamp to minutes in Oracle after a subtraction
I’m trying to get the minute value from a Timestamp after a subtraction First I made a subtraction: Current Time – Target Time(INSP_FIN_DT) ( TO_TIMESTAMP(TO_CHAR(SYSDATE,’YYYY-MM-DD HH24:MI:SS’),’…
Ignore SQL INNER JOIN if specific record exist?
i got two table joined like this I want to display results of two table joined but with condition if the status of TableB has anything in (‘CO’,’CL’) the whole join with id of TableA would be ignored not just the rows with status not in (‘CO’,’CL’). A.id and A.T…
SP2-0552: Bind variable “N3” not declared
This is a code for comparing three numbers and to print the greatest value. When i try to run this pl sql code in oracle it says Can u tell me where it is wrong???I would be very grateful Answer You have 3 errors (typos): You need the DECLARE keyword before you start declaring variables. n2:=&n2: should b…