DB-Fiddle: CREATE TABLE customers ( id int auto_increment primary key, order_date DATE, customerID VARCHAR(255) ); INSERT INTO customers (order_date, customerID ) VALUES (“2020-01-…
SQL GROUP BY and kind of rereduce afterwards
I’m using PostgreSQL v.11. I have a table with 3 columns. My goal is to find redundancy inside data. First of all, I do a simple GROUP BY: SELECT client, block, “date” FROM lines GROUP BY …
Group by column and multiple Rows into One Row multiple columns
Please help me this: I want to group by column TestType, but Result should be splitted into colunms if they have same TestType I want SQL to return data in this format Result# column should be dynamic because each TestType has many Results Answer As I mention in the comments, what you need here is a PIVOT or …
Postgres – calculate total working hours based on IN and OUT entry
I have the below tables: 1) My Company table id | c_name | c_code | status —-+————+———-+——– 1 | AAAAAAAAAA | AA1234 | Active 2) My User table id | c_id | …
SQL Pivot count incomplete and complete
First of let me start by saying that my SQL know how is pretty limited. So I have below table Now I would like to create a pivot in SQL that looks like so Now PN from second column can repeat from …
Extract multiple string elements in table column using Impala or Hive
I have a column A which elements consist of lists with multiple string elements (not arrays), such as: **A** 1 ‘A123′,’B234′,’C123’ 2 ‘A123′,’B234’ 3 ‘A124’, The amount of list elements varies …
Import and display a jpeg from a SQL Server database using r
Work has asked us to import a series of jpeg files from a SQL Server database for display on a dashboard product we have. We are using R to query our db and build our dashboards so we need to be able …
SQL Server – Aggregate data by minute over multiple days
Context I’m using Microsoft SQL Server 2016. There is a database table “Raw_data”, that contains the status of a machine, together with it’s starting time. There are several machines and …
Efficient way to ignore whitespace in DB2?
I am running queries in a large IBM DB2 database table (let’s call it T) and have found that the cells for column Identifier tend to be padded not just on the margins, but in between as well, as in: ‘ ID1 ID2 ‘. I do not have rights to update this DB, nor would I, given a number of
Snowflake Json array/square brackets around all objects
I’m transforming Data in a JSON by using that code and get a result, that is pretty okay. But I need it in another format, so that our agency is able to use the data. This is the Code I use: The Result I get is every row as a JSON with squared brackets, which makes absolutely sense: But what