I have a table with a single column in a Postgres 13.1 database. It consists of many rows with comma-separated values – around 20 elements at most. I want to split the data into multiple columns. But …
Insert into table1 using data from staging_table1 and table2, while using staging_table1 to get the data from table2
Goal: Insert all data into a table from staging table. Each piece of data in the staging table has 2 names which can be found in a separate table. By using the 2 two names, I want to find their …
How to sort columns values in sql db2-400?
I have 10 columns with similar information, and I would like to sort them asc when greater than 0. For instance, from this: A1 A2 A3 A4 A5 A6 A7 A8 A9 A0 00 01 00 09 08 05 00 02 06 03 To this: A1 A2 A3 A4 A5 A6 A7 A8 A9 A0 01 02 03 05 06
SQLPLUS : set sqlformat insert : SP2-0158
I want to export all my datas as insert statement. In Sql Developer, the command “set sqlformat insert” work very well… but when I want to use it on sqlplus, I have this error message : SP2-0158 unknown SET option “sqlformat” This command work when it’s use on a script but i’ve made a script : I’ve try the same
finding missing dates in a time interval (SQL)
I am a bit of a noob with SQL, so I was searching for some bit of code that might help me find missing date values for a time interval when I stumbled upon this code. Link to the code It works really well for my problem but I am not able to understand how it increments the date. I
Get difference from top ranked item
I’m using the following query to rank items, but I need it to also show the difference between the item and the top ranked item (The top ranked item will show the difference between it and the 2nd ranked item.), like so: How do I create the DiffTop column? Answer You can use window functions for this as well: The
How do I check if a column have more than two items and if it have than do the avg() on it in SQL?
I have 4 tables The user and item from buys and rates are foreign keys. I can`t figure out how to put a condition to take out the items which have only one rating and do the average only on the ones who have 2 or more ratings. This is the question in the exercises (For each item that has
temporal joins in hierarchical query
I want to join various nodes of a tree, making sure the the returned root-to-leaf path is temporally valid. The tricky part is that the data source is dated with validity from-to dates. ID NVALUE VFROM VTO 1 A 2021-01-01 2021-01-31 1 B 2021-02-01 2021-02-28 2 C 2021-01-01 2021-02-28 3 D 2021-01-01 2021-01-31 3 E 2021-02-01 2021-02-28 the links are
jOOQ – DefaultRecordMapper – List
Can the DefaultRecordMapper handle lists? Model example (really getter/setter are used): class Head { public Integer id; public List positions; … } class Position { …
Oracle 10g sql query
I have some data like this ↓ T_ID T_PERIOD T_COUNT T_SUM T_UPDATE_COUNT 1 2013-2014 3436 20118043 0 2 2014-2015 4298 27101356 0 3 2015-…