I have the following string ’06/30/2020;58044.373;.001;12/31/2020;58042.373;.003;06/30/2021;78044.373;.007′ I need to transform it into : col 1 col 2 col 3 —- —– –…
SQL Server : Stored Procedure for Preventing Duplicated Values
I have this code which I have created which I want to stop any duplicated values from being inserted into the database, however the values still continue to be able to get into the IF_Translations …
SQL not returning a value if no row exist for time queried
I’m writing this SQL query which returns the number of records created in an hour in last 24 hours. I’m getting the result for only those hours that have a non zero value. If no records were created, …
Whats the disadvantage of setting a too high batch size?
I set the batch_size in application.yml: spring: profiles: dev jpa: properties: hibernate: generate_statistics: true jdbc: batch_size: 20 Whats the reason …
Find by multiple columns and rows criteria sql query
I have Paths and Criteria tables in PostgreSQL. Paths have multiple criteria that should be fulfilled to be selected. Path table with (id, name), Criteria table with (id, key, value, path_id) I …
How to calculate a non-inflated count from a denormalized table
Suppose I have a denormalized table that includes an ID and a value that I need to count. Something like this: In this case, select Tree_ID, count(Count_If_True) from Table group by Tree_ID would show: But If I denormalize my table further with a join from an Apples table (where every tree has multiple apples…
How can I group data from multiple rows into the same row?
I have a query: That returns I want to combine the rows and take one value from each column (doesn’t matter which, first, last, can be any) So one elementary school, one high school, one university. It would look like: However, when I try to group by: I’m getting only a value for one of the column…
How to add fictional rows to an SQL results in Oracle without à grouping
here is my issue, I’m working on an existing big report and they want me to add fictional rows with specifics values each time row in database meet a condition (let’s say status = Canceld) I simplified the query (1000 lines of SQL Code) to this : if I have two table A and B : and the query is
query to update records count based on relation and constraints
Im trying to update a column (address_count) on my people table that must have the sum of records from another table (people_addresses) plus some constraints. The idea is that, the record on people must exist on people_addresses and must be present on at least one of the other tables (table a, table b) With t…
GROUP by data by time range in postgresql
I want to GROUP by data by time range. The example I have start_date and end_date, and I want the separate range between start_date and end_date on 25 range and get sum value from 1 to 25. Simple presentation of my table: table t1 have: generate_series function to separate on and sum by how this 25 for 2019-1…