I have 3 tables on PostgreSQL: SPENDINGS: STORE: CUSTOMER: I would love to join these tables like this: How can I do that could you help me out please? Answer trim(store.zip_code) is not good for the job because the whitespace is within the zip code text. Use replace(store.zip_code, ‘ ‘, ”) …
Tag: sql
SQL Getting a value from a column where another value is MIN value
I am not that experienced in SQL and I am trying to get a value from a row where another value is the min value. I tried several things and can’t find the answer on this forum. My SQL: So I have a table with all actions a driver has done during the day (Driving, resting, loading,…) and I want
Inserting multiple rows of data into a single column
Absolute SQL beginner here: I have a table ‘students’ with the columns ‘id'(primary key), ‘name’ and ‘mark’. I am now trying to add the marks for a number of students. Just using multiple UPDATE statements like seems rather dull and labor intensive. What would be the …
Join Only Unique Values From 2 Tables
I’m trying to join two MySQL tables, and return only the unique values between them. eg. I want to get as my result a table that only shows the intersections of rows without any duplicates where I’m joining on table1.column1 = table2.column1: Simple joins and unions and I’m ok, but this one …
The native sql query to Postgresql via the @query annotation is not executed
To get the necessary data, I form an SQL query to PostgreSQL, which is a related set of View tables : When I execute these queries from the console in the database sequentially, one after the other, everything works. However, if you run similar queries in the repository via the @query annotation (“̷…
Counting unique values within a time window
I have data that looks like (over 100.000 rows): What I would like: Explanation CONTEXT I want to find out how many people (person) are working in the same location (Location) by looking at a time window (timestamp) of max 10 minutes and checking whether a person is really working simultaneously or just takin…
Split Characters in a cell to individual columns [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 months ago. Improve this question I have a dataset where a column contains 1 and 0 in a single cell which reference security …
Joining 2 Queries without Common Column Fields in SQL?
My issue is in reference to a similar post: Joining tables without a common column in sql server I have 2 queries, each query references different tables, hence the queries do not have common column fields. I want to join the 2 queries together. Let’s take for example the 2 queries has the following dat…
SQL Query to check not repeated values
I’m new to SQL. I wanted to know, How to check the entries which are not repeated for the other entries. Better I give one example. column1 column2 a 1 a 2 a 3 a 4 b 1 b 2 b 3 b 4 c 1 c 2 c 3 I want output as column1 column2 c 4 because c
Include zero counts when grouping by multiple columns and setting filters
I have a table (tbl) containing category (2 categories), impact (3 impacts), company name and date for example: I want to get the count of records for each category and impact and be able to add rows with zero count and also be able to filter by company and date. In the example result set below, the count res…