I need help whit my Code (PostgreSQL). I get in my row Result {{2.0,10}{2.0,10}} but I want {{2.0,10}{3.0,20}}. I don’t know where my error is. Result is text [ ] its must be a 2D Array This is Table1 Nummer Name Result 01 Kevin This is Table2 Nummer Exam ProfNr 01 2.0 10 01 3.0 20 My Code is Answer
Tag: postgresql
Finding max count of product
I am trying to find max count of product. The result must only display the brands which have max number of products in it. Can anyone suggest a better way to display result. Here are the table details: I have used this SQL query below but I am seeing an error below. The result must display the list of the
postgres: Any way to insert multiple tables into another table in the same query?
So I have a bunch of tables and I want to insert them all into another table where all entries from the table and with a label of the name of the title of their table. Here is a sample of what I want to be doing but with also logging in old users at the same time from an
PostgreSQL: `VIEW` returns no rows with `SPLIT_PART()` columns
Problem Description: Hi everyone, I’m having some troubles querying on a VIEW whose columns are, in part, the result of SPLIT_PART() function on og table’s column; I created the VIEW as it follows: My intention was to divide the structured attribute (Clients.Address defined as a string VARCHAR(255…
Insert records into one table using key from another table
I have a table with year, start and end columns like below. It has several years in it. Do not ask me why there is a year called 4 in there because I could not tell you. I just know that it cannot be removed from the table or else the web application will break. I use this query to
Correct value of a json data saved using JPA, spring and kotlin Map
I have a jsonb column in a postgres database where I store a bunch of key/value(1 level) into a column mappped to a a Map<String, Any). The values are supposed to be a String but in code I’m accepting anything. All saved values was passed as ByteArray(byte[]) and it’s stored without problems. T…
Postgresql create trigger for integrity constraint in insert / update
I have these tables on a database on Postgresql: I want to be sure that when I insert / update a value in manager_employee table both manager_id and employee_id belong to the same company, same company_id. I think I have to use a trigger to ensure this condition, how can I create it? Thanks Answer You can do …
how to save database versioning as a sql_last_version variable in logstash
What I’m trying to do is to save the greatest version of rows in the sql_last_value parameter as shown below in my log.conf file after each time it executes. This is my log.conf for logstash: for instance, this is my table: I’m expecting to store 600 as the last_version parameter. I’m sure i…
How to round timestamp to nearest day with postgresql
How can I round a timestamp to the nearest day in postgresql. I have tried using function date_trunc(‘day’, d_date::timestamp) but I get that is always staying in the same day. Example 1: Example 2: (This one works fine) Answer You could add 12 hours to the timestamp and then do the truncation tha…
Correct way to implement nested aggregation in PostgreSQL
I have a table that looks something like this: Multiple foo_id can belong to bar_id, and multiple timestamp can belong to foo_id What I want to do is to count the number of foo_id and the average length of foo_id (i.e. timestamp difference between the last and the first instance of the foo_id), belonging to t…