I have a Postgres table that has an order view field in her, I’m using Nodejs with express This order view is of type INTEGER and has the constraints of NOT NULL and UNIQUE Inserting a new record may bring problems with that, because, if the existing records have view orders of, say, [1, 2, 3, 4, 5], an…
Is there an Azure SQL Database equivalent to MySQL’s “CHECKSUM TABLE”, and should it be used to check if two tables are identical?
I was looking for a way to check if two tables in the same database are identical (both contents and schema), and came over this question. The top answer for the question uses (from my understanding) a MySQL specific. When trying to run the code in an Azure SQL Database I get this error: Incorrect syntax near…
How to write SQL query without iterations
I have the following challenge: I have a table called hashtags_users_grouped which has the following structure: In each row, we find values that tell me when a certain user mentioned a certain hashtag and how many times he did it. In this example, user 1 mentioned hashtag 123 one time and 245 three times, whi…
Generate Scripts to move a database from one server to another
I want to move a database from our testing server to my local server. I don’t have the option of back up and restore since I don’t have permission. So I decided to use the generate script option to create all the scripts for the DB and then move over the database to my local server. The problem I&…
Using Variables in a MSAccess Function with SQL
I’m struggling with entering a custom made ID number on all my tables to link all records together, trying out normalization. I have an EmployeeDetails table and a LoginDetails table. Its my understanding that I need a field called EmployeeID on both and I can use the SQL Select code I have to pull the …
How to insert result of select query (with default if return no rows) as part of Postgres Function?
For my Nextjs website, I am configuring the backend to automatically add user information to a public.profiles table whenever a row is inserted into the auth.users table (automatically done through Supabase’s authentication). I have a public.college_emails table that contains the names of over 1700 coll…
SQL – Guarantee at least n unique users with 2 appearances each in query
I’m working with AWS Personalize and one of the service Quotas is to have “At least 1000 records containing a min of 25 unique users with at least 2 records each”, I know my raw data has those numbers but I’m trying to find a way to guarantee that those numbers will always be met, even…
Merging pandas DataFrames generated with a loop on SQL Database Data
This works BUT the outputs are not matching on the index (Date). Instead the new columns are added but start at the first dataframes last row i.e. the data is stacked “on top” of each other so the Date index is repeated. Is there a way to iterate and create columns that are matched by Date? Output…
Sequelize – How to get reviews for post with likes count for each review
I have a function like this. It receives comments on the post. And it doesn’t work – it makes endless requests. If we remove this line, the function returns one comment with counted likes. And if you remove this block: … then the function will return an ARRAY of comments. Why does the like c…
MySQL #1140 – I want to display the minimum salary, it gives this error
I want to display the minimum salary, it gives this error I have to take out one person who gets the lowest salary not using group by MySql error: #1140 – In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column ‘football_club.player.name_surname’; thi…