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
T-SQL :: Error converting data type varchar to numeric when changing 1 to 0.5
I’m writing a complex T-SQL query with CASE that will help me calculate how much time it will take me to migrate databases based on the size of each database: All good, it works when I set 1 hour of work for every database which has less then 100.00 MB. Also all other values are summed and in the Hours
How to find a destinct values in a table that are larger than all values that reference it?
I need to find the names of bosses who were hired after all the hired date of all their subordinates. Here is what I have got so far: SELECT DISTINCT TRIM(boss.first_name || ‘ ‘ || boss.last_name)…
How to split an array of objects in SQL?
I have a table in my database which has the following columns: ID Data 1 [{“na”:false,”answer”:1.5},{“na”:false,”answer”:0.5}] 2 [{“na&…
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…
String table name not working in a query with psycopg2
I would like to generate dynamic queries with variables for column names and table name. This is my code: query = sql.SQL(“select {fields} from {table}”).format(fields=sql.SQL(‘,’).join([ …
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
PYTHON – Dynamically update multiple columns using a custom MariaDB connector
While reading this question: SQL Multiple Updates vs single Update performance I was wondering how could I dynamically implement an update for several variables at the same time using a connector like MariaDB’s. Reading the official documentation I did not find anything similar. This question is similar…
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…
I am trying to Join Xn tables on SQL and I am getting a syntax error
I tried this (Select o.OrderId,o.CustomerID, p.ProductName from OrderDetails od inner join Products p on od.ProductID = p.ProductID inner join Orders o on od.OrderID = o.OrderID) Inner join …