I have two tables A and B. In A, I have a column called fetch_year. I need to consider table B from these two columns primary_date secondary_date These columns have JSON values like {“lock”…
Retrieve the correct disk space usage of a columnstore index in MSSQL
I was trying to retrieve the exact amount of bytes required by a clustered columnstore index in MSSQL. Unfortunately I get different result from sp_spaceused compared to a simple query on sys.allocation_units. Here the simple script: Here the sp_spaceused result: Then I try to get the amount of occupied pages…
Skip rows in an unsorted list
I have an Angular app which displays a list and a Scala API which provides data. I encountered a problem (and the languages don’t matter, is just about logic). The problem is that the table from which I get data doesn’t have a primary key. Because I need to display the data plain in a widget (of t…
How to filter PostgresSQL query result dependent on value on some column?
I have this query: Which results in this: Instead of returning all the 4 rows, I’d like to return the column which has a value “1”. How can I achieve this? Answer If you just want it to show the column with value = 1, you already have the answer. With mi answer you select all the columns wit…
Write query with HAVING clause in Kotlin with Exposed
I have written an SQL query in which I use the HAVING clause. However, I have not found practical examples of the use of HAVING in the Exhibited documentation. My query should return the following: Disputes for an order that has the most recent status of ‘CAPTURED’ or ‘EXPIRED’ My bigg…
Query has no destination for result data in function PostgreSQL
I have a function that returns results to me, but the result is not what I expected and capturing the error message I get this: query has no destination for result data this is my code postgresql: …
Why this mysql statement returns whole table?
I am wondering that how this query returns all data from the table: It gives the same output of this: It is probably works as this: but, WHY? Answer Break the WHERE condition down, and this starts to make sense: All rows with an email attribute set to a blank string ” will return TRUE. For a minute, let…
Max from joined table based on value from first table
I have 2 tables. First holds job details, second one the history of those job runs. First one also contains job period, per customer which is minimum time to wait before running next job for same customer. The time comparison needs to happen on started_on field of second table. I need to find out the job ids …
sql Tables manipulation
Hi everyone, i have the above table ‘given table’ i would like to create a new table with columns ‘product’, ‘paid’ , ‘branchA’ and ‘branchB’ as shown in the ‘desired output table’ with the unique identifier column ‘id’. This …
SQL mixed String with leading zeros
I want to get the maximum value of a table and then add that with +1. The problem here is that the column contains leading zeros and the length of the column cannot be greater than 4. Here an example: Tablename: car id C001 C002 … C009 I have tried to solve this problem with this sql Query: result: C001…