I have data in one table in a oracle database and I want to “split” this table in SQLplus into ten tables based on the content of one column. Source table is all_data with columns: kind, time_period, …
Redshift get Json Keys
I have a table field with a value like this: { “0fc8a2a1-e334-43b8-9311-ce46da9cd32c”: { “alert”: “345”, “channel”: “ios_push”, …
Get data horizontal in SQL
I have this query: It’s returning: I’m trying to make it like this, if anyone could help me, thanks Answer You can pivot using conditional aggregation: It is unclear what the specific values are that go into each column.
SQL – Time difference between rows, conditional
I have a database for logging peeing/pooing time for a puppy. Each row contains a timestamp datetime, and bools pee and poo. I’m trying to add a column for the time since last pee/poo. The verbose version of this column would be: subtract this row’s datetime from datetime of the row with the highe…
Dynamic SQL :: Calculate percentage of NULLs per index
I have a query that help me list all index in a database and works pretty well: Unfortunately if I uncomment the 6th line the word t.name is underlined in red and if I run the query I receive the error: How can I make this subquery work? The goal is to have a percentage of NULLs on each column
How to update table with data from another table
I have two tables First table INTRA.TABLE_A Second table EXTRA.TABLE_B And I am trying to get data from INTRA.TABLE_A into EXTRA.TABLE_B with update: But it “throws” syntax error at FROM word: syntax_error After update, result should looks like: I am using sqlDeveloper and Oracle database. How can…
Creating a trigger with SELECT Function
Good day everyone, I’m having trouble making my trigger work. As far as the functionality of the body and how it behaves, it does exactly as I intended for it to behave. However, when I start to fire the trigger, it returns an error in which Triggers should not have a SELECT statement from inside the ma…
left join taking too long
I have an issue with query performance and cant find out how to fix it. Both tables have 20k rows Prod_id like indexes but not primary key because table 1 has duplicates with different month, year etc I need to get table like this (table1 * wh = 80k rows): I’m using LEFT JOIN to do this but takes too
Just wondering how can i convert this below query to a oracle query using merge statement?
Answer With what you posted so far, could be something like this (presuming that last line’s IN_WFID represents some kind of a parameter):
SQL query base on three relation with restriction
Customer (CustomerID, FirstName, LastName, Email, PostCode) Salesman (SalesmanNo, empName) Account (AccountNo, SalesmanNo, CustomerID, AccountType) How do I achieve this: Get the name of customer purchase from both Sean and Jean, i believe with the below nested query statement I get the customerID who purchas…