I’m current facing a issue in my project. When i search a product, it take too much time to fetch data. This is sql code. SELECT * FROM product_info LEFT JOIN ( SELECT bulk_stock_info….
Calendar Count Grouped By Client Customer From Subquery in results showing active client by month
I am running into an issue with a query I wrote that displays an active count of ID’s for all clients per month for the previous 12 months. The issue is that this count displays the same through all …
How to transform my existing table into this specific format using T-SQL?
I am using SQL Server 2014. I have a table T1 (extract shown below): I would like to have the following output using a T-SQL query: The logic here is that data related to a specific ProfileID is to be transformed into the wide format. The StayID column is always unique. I have been looking into the pivot func…
A more efficient way to organize a DB schema for key value storage in a related table
Here is the DB schema that I currently use (some tables and table columns have been removed and the rest have been renamed for simplicity). I’ve added some indexes and at the bottom there are sample …
sql; concatenate MIN(price) and MAX(price) into column?
I am working on an aws athena query like so: Which will give results like so: Right now I have maxprice and minprice as two separate columns, but I want to combine them into one column “price range” which will have minprice and maxprice separated by a ” – ” string, so it would lo…
aws athena SQL query; get unique count of column2 for each unique column1
I am fairly new to SQL queries, and am working with querying an aws athena database. My first query will return every unique brand given some parameters: Returning a list like this: And so on and so on for 553 rows. If I pick any of the brands, such as ‘Seraz’ and run this second query, it will re…
Window functions in SQL: why are they called window functions?
I understand window function but don’t understand why they are called window functions. When we say the “window” is it both the partition and the order by clauses? Answer Window functions operate on a range of rows, defined by the OVER clause. It is like you are looking through the window, y…
MySQL generate a sublist of comment in a query
I have a database of 3 tables Question, Answer, Comment it works as it is supposed to, each Question can have multiple Answers and each Answer can have multiple Comments create table Question( …
JPA Criteria Builder query with inner SELECT statement
I need to create the below SQL join condition using JPA criteria builder, Below is the entity class and JPA query builder. I am able to build the query with join condition but cannot create the inner SELECT query. How can i create a inner select query for join clause? Requirement description: The below is the…
SQLite – How to use VARIABLE for TABLE NAME + VARIABLE FOR INSERT VALUES
im new in programing, starting with python I found this script in a post (link below) query = ‘SELECT * FROM {}’.format(table) c.execute(query) How to use variable for SQLite table name it worked, …