I am using Testcontainers 1.15.2 (using postgres image 13.2-alpine) with Spring Boot 2.4.3. The Testcontainer is started using an init script which starts with a type definition, a table creation and …
Creating a row number column based on another columns value
I have the following data: it’s a calendar that has date and year/week number there week is our internal calendar. what i want to do is sort by the most recent week number and have that be rel_week_index=1, and then the previous week be rel_week_index=2, etc. I got this to work by doing ROW_NUMBER() OVE…
MySQL Java prepared statement Syntax error
I need to select rows from mysql table based on various criteria, for example Colour= Black, or size= L. The code works without the preparedstatement and the question marks, but whenever I attempt to use the question marks the code does not run. I have read something about typing the question mark like ‘…
Laravel (8.x) Is there a better Eloquent query for this many-to-many filtering problem?
What I have movies many-to-many stars movies many-to-many tags studio one-to-many movies I pass studio name, star name and/or tag name as optional query strings What I need Select all movies with tag and star and studio if all 3 are passed as params Select all movies with tag and star if those 2 are passed as…
Do I need to perform a Join in order to merge multiple columns with 0 in them
I may have asked this question incorrectly but I have the following query where I’m trying to pull 3 different metrics for a given store. When I pull them though it comes out as below: Is there a way …
SQL – % Breakout by Hour
I’m trying to write a query that will break out what percentage of time is utilized within a hour given a time range. Sample data: declare @date table(id int, Start_time time, End_time time) …
How to do a join to get previous days values?
I want to join tables as follow: Report_Period Entity Tag Users Count Report_Period_M-1 Report_Period_D-1 … 2021-03-31 entity 1 X 471 2017-05-31 2021-03-18 … 2020-12-31 entity 2 A 135 2020-11-30 2021-03-18 … 2020-11-30 entity 3 X 402 2020-10-31 2021-03-18 … With a view containing Day &…
T-SQL – subqueries on rows grouped by ID to create a summary table
I have a table “MyTable” with an id and two int fields “A” and “B”: MyTable +——-+—–+—–+ | ID | A | B | +——-+—–+—–+ | 99 | 0 | 1 | | …
Create a stored procedure to populate a table with one row-Yearly and Monthly Averages
I have created a stored procedure to populate a log table. I am having trouble with the syntax for columns H and I. Is there something wrong with my syntax as it relates to monthly and yearly …
Perform a particular ILIKE query on Postgresql
I have a problem with a query in Postgres. I have a column with values such as: id@@@Name1@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### id@@@Name2@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### id@@@Name3@@@other text@@@other_text@@@other_text@@@CODE@@@other_text### Each row ca…