Skip to content

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 …

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…

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…