I have an interesting issue where I need to create a unique identifier based on match groups for a set of data. This is is based on multiple criteria, but generally what I need to happen is to take this input: SOURCE_ID MATCH_ID PHONE 1 1 (999)9999999 1 2 (999)9999999 2 1 (999)9999999 213710 707187 (001)25489…
How do I do multiple CASE WHEN, using LEAD() to look at an entire row in SQL?
I have a set of data that I need to manually adjust a column (inserting 0) for the row trailing a specific row, based on a record in one specific column. For example: My desired output: TYPE ObjectID DATE AMT1 AMT2 AMT3 AMT4 TOTAL AMT C 1234 3/1 2 0 2 2 4 A 1234 3/2 5 0 0 0
MySql using interval with a list of dates
I’m willing to fetch all the dates that are listed in the list reducing 1 day I’m trying something like that: I wish to receive: ‘2022-03-21’, ‘2022-03-17’, ‘2022-03-10’ Answer It can be done with intervals. Here is a link to how it works : https://www.db-fiddle…
Error: Returned type unknown at ordinal position 2, but query expects text
I created an SQL function in PostgreSQL that returns a table with text values, it is throwing error Function definition: Answer You could try casting the string literals explicitly to text using the double colon operator:
Find ID which doesn’t exist from another table
I am studying SQL and I am not sure which is the way to filtering data. For example, there I have two tables: Reference_OrderTable: OrderID Item Price OrderTable: OrderID Item Price Reference_Ordertable: this table has all the type of orders. OrderTable: this is the actual order table, we store by customer…
How to rotate a two-column table?
This might be a novice question – I’m still learning. I’m on PostgreSQL 9.6 with the following query: My query returns the following dynamic rows: locales count en 10 fr 7 de 3 n additional locales (~300)… n-count I’m trying to rotate it so that locale values end up as columns with a s…
BCP queryout hangs with READ COMMITTED transaction isolation
Using SQL Server 2016 and bcp version 14 My query returns about 16k rows and runs quickly to completion in SSMS with the default (READ COMMITTED) isolation level however if I try to save the output of the same query using BCP the tool hangs. If I set isolation level to READ UNCOMMITTED in the BCP query then i…
How to use group by with case statement [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 8 months ago. Improve this question I ha…
Nest Postgresql Sequelize one-to-one Error with ForeignKey
My Table Has one-to-one connection with table But when i try add some data in second table< i got an Error – Nest error insert or update on table “checkingResults” violates foreign key constraint “checkingResults_resultId_fkey” What happened? I try any thing… And how i r…
sql query that depends on each value of other table
I’m not used to query sentences and this one is a bit tricky, I don’t know even if it is possible (at least with just a single sql query) or if I should change the question name to something more accurated, if so let me know. I have two tables, I will make them simple. The first one that is