I want to loop the code shown below. I would like to use the [getpublicholidays] function for a variable number of years and merge them (union). Unfortunately I don’t know how to use the function in a loop with union. Can someone help? Answer If you are looping for X years, each time you loop to a new y…
Does order of the data in the table affect it’s performance? RLE compression
I use the Greenplum database – massively multi-parallel Postgres. I have a table which that has 100 gb. There is data from 2019 up to today. The table is not ordered, but every day we insert new data. So it’s kinda sorted by a sales day. I would like to recreate this table, but I would like to sor…
how do i increment a value of column with condition?
my table looks something like this i have a function, which return 1to3 int value representing effect1,effect2,effect3 and “id” i am trying to increment value of each effect by 1 when my function’s returning “id” matches the “id” from my dataset otherwise creates new …
Select all groups that contain all specified values in a certain column
Say I have the following table: CaseRef NotificationReason NotificationDate 123 SCHEDULED 2022-01-01 234 SCHEDULED 2022-01-02 312 SCHEDULED 2022-01-01 123 RESCHEDULED 2022-01-02 123 DECIDED 2022-01-03 234 DECIDED 2022-01-02 If I want to return only rows that have a CaseRef that has both a SCHEDULED and a DECI…
How to do update/migration of data, with help of generic query
I am in middle of trying to get better with sql, but I have some issue/question with one of my exercies. So I thought about this kind of following situation. I have three tables: STUDENT COURSE STUDENT_COURSE But after some time I have requirments to divide courses into more specific names. So in COURSE table…
Validate that a new username doesn’t match a pre-existing username
I wanted to implement a validation in my SQL stored procedure that’s designed to create new users. I wanted to validate that a new user can’t use the same username as another user. This is my current stored procedure: I assume I need to do something using an if statement that takes the value enter…
Javascript print SQL first item in ResultSet without comma, then all others with comma
Current output: Desired output: How can I do this in javascript within the sql stored procedure? I would like to not have to execute the query more than once because the actual query is computationally intensive. Answer you can add boolean check if this first or not:
How can I write a Postgres (SQL) query for FIFO ‘closing stock’ inventory valuation?
Background I need to implement inventory valuation / costing using the FIFO (first-in, first-out) method. I’m running Postgres 11 running on CentOS 7. I’ve looked at, and tried, a fair number of hypotheses from SO and the wider internet (as well as searching my own print library which includes SQL…
How to “hide” a row in Oracle SQL database but not delete it
Is there a way to “hide” a row in Oracle SQL database without deleting it, So that it is still in the database but does not show up on the webpage as a search result? For example, I want to hide a specific city in my database from being displayed in the results when searching for cities on the web…
How to get a list of all Table names through asp.net API controller
So I want to get a list of all the table names from the database through a controller as an ASP.net API project. I tried to do it through raw sql query without entity and it looked something like this. But when I try to use the SqlQuery method I get the error ” ‘DatabaseFacade’ does not cont…