When I try to return a table, my results are showing up like this generateClassRecord ——————– (james, 5) (bob, 10) rather than like this +——-+———-+ | name | new_rank | +——-…
SQL – WHERE for 2nd SELECT object
I’m trying to find an average of 2 items in my SQL table, an average commission of people who receive a commission from the table, and an average commission, including those who do not get a …
HIVE Query: How to select the ‘join key’ for “FULL OUTER JOIN”?
I got the following error: Multiple attributes named business_id in reportAttributeReferenceAmbiguous; p.business_id, s.business_id from the SPARK/HIVE query: SELECT business_id, p.p1, p….
How to return custom record with calculated data
I want to return a custom empRecord row. How can I do this? Please do not change the select statement. Essentially I just want to return the name of an employee and a new rank. CREATE TABLE employees …
Understand the logical query processing when ‘Between’ condition is used in a self join of a SQL query
I have the following Orders table in PostgreSQL Database I need to return the cumulative sum of revenue for every order_date from last 2 days including the revenue for that order date. I am using the following query and it returns following result As per logical order of the query processing following steps w…
DB2 : SQL: Change in granularity for SCD type-2 table
I have a order table in SCD type-2 like below (Delivery Date in Order granularity and it create history when when delivery date changes) Order_Id Order_Status Order_Create_Dt Delivery_Dt Start_Date …
MySQL GROUP BY slows down query x1000 times
I’m struggling with setting up proper, effective index for my Django application which uses MySQL database. The problem is about article table which for now has a little more than 1 million rows and querying isn’t as fast as we want. Article table structure looks more or less like below: After man…
Multiple select statements in single query while using ‘group by’ and ‘join’
I have three tables – podcasts, videos and others. Each of the entities under these are associated with a category and subcategories. Example for podcasts – This category_id and subcategory_id have their name values in their respective tables – Now, I want to get the count of podcasts, video…
Eloquent hasMany doesn’t load collection
I’m relatively new to eloquent, and have problems loading data from a hasMany relation in an app that uses eloquent as the database layer. My (simplified) code is as follows: The SQL Schema is like below I then do the following query: This results in a json like the following Raw SQL query shows me that…
How to find if a list/set is exactly within another list
My question is basically an extension of this question – How to find if a list/set is contained within another list I have the same data, but with more exact same products – order_id | product_id —–…