Questions tagged [nested-select]

Nested SELECT is used when some select query is used under a select query like SELECT * FROM (SELECT * FROM TABLE)

46 questions
0
votes
0 answers

Need to compose a MySQL query and several SELECT and nested queries

I need to get a list of the stores that the company has, and I need to output the number of products in each of those stores. The list of stores and items are different tables and I need to merge all of this to output a common answer. To have all…
IndieDev
  • 1
  • 1
0
votes
1 answer

Nested selects when dealing with calculated columns

I'm trying to write a nested select statement that returns a single row that emulates the batting average from this site https://www.espn.com/mlb/team/stats/_/name/hou/season/2005/seasontype/2/table/batting/sort/avg/dir/desc. I encountered a divide…
hudg
  • 1
  • 1
0
votes
0 answers

Mysql return value with nested Select

I am writing some software for a restaurant. They change prices on certain dates. I have two tables, one with the products ordered by order, and another with prices, historical, that is, every time they change a price, I set a bit to 0 to the old…
CRevilla
  • 1
  • 1
0
votes
1 answer

Nested query in MySQL using select statement

I am having trouble with the activity I have in MySQL. Below are the tables of my employee database, and I want to show the dept_name column from the department table, first_name and last_name from the employee table, and the title_name from the…
Ghost
  • 3
  • 1
0
votes
1 answer

Calculate lift for every row and compare it with the average lift of region and year

I have a table that looks like the one below: Shop Year Region Waste Avg Waste (Year,Region) Lift Column_I_want_To_Calculate (apply case when statements) CASE WHEN Lift > Avg(Lift) OVER (PARTITION BY YEAR, REGION) THEN 1 ELSE 0…
NikSp
  • 1,262
  • 2
  • 19
  • 42
0
votes
2 answers

SQL column of sums of multiple rows while keeping all rows?

So I have a query select that outputs something like this: (the actual results I'm working with is much more complicated but these are the important parts) id trans 123 5.00 124 6.00 124 7.00 125 8.00 125 9.00 I want to create a result…
0
votes
2 answers

Angular Material Nested Select from service

I´m working on a nested select in angular material, the data of this two selects is in a json file: [ { "id": 1, "name": "Arquitectura", "depcen": [ { "name": "Diseño" }, …
Laura Díaz
  • 85
  • 1
  • 9
0
votes
1 answer

SQL: create global alias for nested SELECT to be used in another nested SELECT

Let's assume I've got a database with two tables: people which contains person's id and his/her birth year for each person and parents which contains the (parent_id, child_id) pairs to represent the relative relationships between people. To make the…
Kolay.Ne
  • 1,345
  • 1
  • 8
  • 23
0
votes
0 answers

How can i hide unselected options items on nested select in angular material multi select?

I need a help about angular material select-boxes. When i select items in first tab i must to view in two nested one single and one multi-select box on other tab. Then i must to view selected combinations by adding them in List or table. Here is…
0
votes
1 answer

suppress/eliminate datagrip sql reformatting for nested selects

In datagrip's SQL editor, if I start with a sql select like select col1, col2, col3 from table1 and then wrap it in parentheses in a nested select context, it resets all my lines, viz: select t1.* from ( select col1 , col2 , col3 …
ouonomos
  • 700
  • 1
  • 9
  • 25
0
votes
2 answers

Selecting all rows with a column that is contained in query result

I have two tables: CREATE TABLE Master ( url TEXT PRIMARY KEY, masterId TEXT, ); CREATE TABLE Version ( verId TEXT PRIMARY KEY, isPending INTEGER, masterId TEXT, FOREIGN KEY(masterId) REFERENCES Master(masterId) ); I want…
Sanich
  • 1,739
  • 6
  • 25
  • 43
0
votes
1 answer

alternative to nested select mysql

I am running a query at the moment, and I believe that that nest selected is creating a bottle neck, is there an alternative option that I could use? This is my query, SELECT…
Udders
  • 6,914
  • 24
  • 102
  • 194
0
votes
1 answer

SQL lambda output not correct using nested select

I have 2 tables, Terms and Site_Program_Term: Terms columns: Id, SiteId, Name, IsHoliday, DateStart, DateEnd, Year, IsActive Site_Program_Term columns: Id, ProgName, SiteId, TermId, Year Using the above 2 tables, I need to display output with…
Sachin Kaw
  • 33
  • 4
0
votes
1 answer

Update duplicate value in MySql with nested select

Please help me with my MySql Script, I caught up with an error. I have a Table (tbl_products) with the field of p_id and prod_skuid i wanted to update all duplicate prod_skuid into my tbl_products. Here is my MySql script: UPDATE tbl_product t1 SET…
Leonard
  • 19
  • 9
0
votes
1 answer

MySQL select most recent from multiple columns

I have a table that has multiple date columns, the following is an example of my table columns: tbl.user_id, tbl.date_1, tbl.date_2, tbl.date_3 I need to come up with a query that will return user_id and most_recent_date where most most_recent_date…
Ross
  • 112
  • 1
  • 17