I have a task in school which requires me to create a table and a trigger. I don’t really know how to explain it but how can I check if cID is inside the select statement within the trigger function ? …
Tag: sql
PostgreSQL Integer in Array is not merge-joinable
I would like to perform a FULL OUTER JOIN ON a condition that is an integer being in an array of integer. The query would look something like this: SELECT thing FROM table1 t1 FULL OUTER JOIN table2 …
week number as column name
first of all my sql statement: SELECT DISTINCT ( SELECT SUM(Preis1) FROM tblBuchungsdaten WHERE (Datum BETWEEN DATEADD(wk, -7, DATEADD(DAY, 1-DATEPART(WEEKDAY, GETDATE()), DATEDIFF(dd, 0, …
Syntax error in SQL when inserting data via nodejs
I have a simple nodejs code in pipedream that sends the body email to mySQL Database. i have checked the connection to database and its working. Here is my code const mysql = require(‘mysql2/promise’);…
Selecting records in SQL table if either JOIN statement is satisfied
I have a table of Companies that I’d like to filter to just the records that are referenced from two other tables, Employees and Contracts. My initial instinct is that I might be able to do something …
window functions and grouping – how to propagate data from row 1 through row 3 in a partition?
I have this query below: select Contact.IndividualID, Contact.IndividualID as ContactId, Contact.CaseNumber as CaseID, [Case].ProgramCode as Benefit, Contact.Email as EmailAddress, …
Cumulative balance across two tables
I want to get data from 2 tables ordering them by date: to get the cumulative balance for the customer The 2 tables that I want to get data from are my tables: transfers & trans_payments transfers:…
How to format in PostgreSQL CITEXT variable to a regex to be used for search
First of all – all credits goes to Laurenz Albe answer here I hava a JSONB colum where I need to perform a search on the values (exactly as explained in the linked question). I think to get advantage …
postgres procedure list of values
I’m trying to pass in a list of values into a Postgres 11 procedure. The query has an IN condition. How do I pass in a list of values to the procedure & then how do I use it in the query? create …
How to edit my postgreSQL query to select the most recent row by date for several columns
I have a query where I’m trying to select the most recent row based on date. So what I would like my query to do is to select the most recent datapoints for a couple columns in my database. sql = f&…