Skip to content

SQL – Adding columns

I am new to SQL and was wondering if someone can help me with this small request. I am trying to have my output like down below: But I am currently getting this output: Here is my SQL code: How can I get the columns to reflect MF, CH_A, CH_B, and CH_C with its respective value? Answer @Med2020 Your query

How could I speed up this SQL query?

I have this query: With this explain plan: https://explain.depesz.com/s/gJXC I have these indexes: Is it possible to further optimise this? There are only 30 time intervals for this table so I feel like I should be able to get it faster. Answer A main limitation here (at least if you have CPUs to spare) is th…

Separate columns by commas ignoring nulls

I have the below table: A B C D E A1 null C1 null E1 A2 B2 C2 null null null null C3 null E3 I would like the below output (separated by commas, if any value is null, then do not add a comma): F A1, C1, E1 A2, B2, C2 C3, E3 Answer You can concatenate all columns

PostGIS: Transform Linestring to LineString ZM

Problem: I have a series of geometries (LineString) saved in a Postgres database with additional information saved next to the geometry (a column for speed and time). I want to combine the three columns into a LineString ZM type so the geometry goes from a 2d to a 4d vector. id geometry speed time 1 LineStrin…