A
A
AndrFK2021-03-26 18:01:14
SQL
AndrFK, 2021-03-26 18:01:14

SQL - how to add fields to a table in ascending date order?

Hello.
There is a table
ID color date
37654 green 24.05.2020
87564 red 24.05.2020
54211 Green
02.24.2020 75604 yellow
01/11/2017 54211 Red 10.03.2021
874453 Yellow 12.04.2020
54211 Yellow 12.03.2020
98764 Green 10.05.2019
45 green green
98764 yellow 10/10/2018
7423 red 06/14/2020

How can I make another table out of it:

id color_date1 color_date2 color_date3
45 green NULL NULL
7423 red NULL NULL
37654 green NULL NULL
54211 green yellow red
75604 yellow NULL NULL
87564 red NULL NULL
98764 yellow green NULL
874453 yellow NULL NULL

I.e. I want to filter everything in ascending order of 'id' and 'date', and if 'id' is repeated, each subsequent value in 'color' will be added to the added column (there can be up to 10).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman, 2021-03-26
SQL

insert into <посмотреть синтаксис в документации> 
select <выбрать как вам хочется>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question