I have a dataset that has a product, weeknumber, and sales for that week. I am trying to find the 4 best consecutive sales weeks in the data, so for example, Product A’s 4 best weeks are 1-4 and Product S’s best weeks are 5-8 I am using SQL to query the table to return the 4 best consecutive weeks
Convention for IDs of child tables
Every tutorial that I watched implemented child tables with two IDs, one ID for the table itself, and one ID that was just a reference to the parent’s table ID, like so: In my project, I’m doing a discord bot, and the only identifier that I need is the server’s ID. There’s no need for …
select only those who have no contact
I updated my question. I have table like this: id name contact 1 A 65489 1 A 1 A 45564 2 B so, i want table like this: id name contact 2 B Answer Using exists logic we can try: In plain English, the above query says to return any records for which we cannot find another record belonging to
Multiple sum subqueries for percentage
I need help with the following problem: I want to make a query that contains multiples sums and then takes those sums and uses them to get a percentage: percentage= s1/s1+s2. I have as input the following data: Orders shipping date, Nb of orders that have arrived late, Nb of orders that have arrived on time W…
Athena Unnest Map key value pairs where key is null
Assuming I have rows in Athena and a column in each row may be empty, or contain json with key value pairs, I am trying to select the key value pairs as rows using UNNEST, but enable me to select …
How to select different values in different dates in SQL
Im trying to get the number of customers that a company had each day for the last 7 days. But when I run my code I get the total of customers for the week and is just displaying the last order date. …
Group by calculated field within multiple inner joins / subselects
I’m trying to find stories that are the closest distance from the user. However, only chapters in our stories have a place, so I need to get those items and then get the closest chapter from that list,…
Union statement statement in SQLAlchemy
I have multiple large csv files that I want to merge and store the final table in a database for using in Pandas in the future. I read them all using Pandas and store them as separate but similar …
Should I care about sql injection after user has been authenticated?
Does make sense to check on malicious SQL input from an authenticated user? Answer An authenticated user can inject queries that bypasses his security settings if such a query doesn’t enforce security checks on fields/objects. Also if a class is defined as without sharing, a simple where clause addition…
how to make the datagridview load faster with Multiple Row query – c# SQL
The code: The SSMS output: The output form loads slowly, the rows for the query are over 1000 so I think the cause of the slow load is the number of returned rows? If yes, how do make the load of the datagridview faster? Answer NOTE – this answer relates to the first part of the original question regard…