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…
Tag: sql
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…
Join on existing aggregate query to pivot result without id
On a Sql-Server instance, I have three tables: ActionItem Id Name 1 Fish 2 Gravy 3 Pants ActionData Id ActionId Group Field Value 1 1 1 1 100 2 1 1 2 200 3 1 1 3 300 4 1 1 4 NULL 5 1 1 5 NULL 6 1 2 6 “Some Text” 7 2 1 1 50 8
Daily User Retention for a month mySQL
I have log_event table and which has table as shown below: db<>fiddle I wanted Daily user retention(day-1) for Aug’18. Day-1 retention: Users who registered on day-0 and then opened app on day-1. For ex: In short users who registered on like 15th Aug 2018 and opened app on 16th Aug 2018 Answer You…
Get every unique pair combination of a column in SQL
Lets say I have given table: How do I JOIN / combine the table with itself so I get every possible unique pair combination of the first column: Answer You can do something like this. Cross JOIN is used for cross product
SQL Pivot in BigQuery
I have a SQL table with information about email campaigns that my company has created. Each line of the table is an action that a user has taken on a specific campaign: User ID Campaign Name Status 01 Campaign#1 opened 01 Campaign#1 clicked 01 Campaign#2 opened 02 Campaign#1 opened 02 Campaign#2 opened I want…
How insert if a row not already exists ? (query)
My tables : Wrong migration script : I try insert new row if FirstTable.label == Str Test isn’t already exists but i get an error : SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ” at…
Node.js display all images of a user in ejs from database
I am new to Node.js and right now I am trying to display all my images of a logged in user from my database to my ejs file. I have set up all the code but i have a problem where I don’t know how to properly display all images. I have also tried async functions but i don’t seem