Questions tagged [derived-table]

A derived table is a term in SQL for a set of records that result from one query that can be used in another query. Derived tables are useful in simplifying complex queries into a series of simpler steps. They are often a simpler alternative to using temporary-tables.

A derived table is a term in SQL for a set of records that result from one query that can be used in another query. Derived tables are useful in simplifying complex queries into a series of simpler steps. They are often a simpler alternative to using temporary-tables.

188 questions
0
votes
2 answers

SQL Server - Select Rows in Derived Table that have count > 1 of value in one column

Help please. I have the following Select query and want to select only the rows where the column A.Name repeats more than 1 time: SELECT A.Payer, A.PaymentDate, A.Name FROM (SELECT T.InstitutionRoleXrefLongName AS 'Payer', …
ACL
  • 3
  • 1
  • 2
0
votes
2 answers

Derived Table for single table to fetch correct result Set

I have a table where i need to fetch a result using derived table . Display the products which name starts with either ‘S’ or ‘W’ and which belongs to Stationary and cost more than 300 Rs . I have tried but i got multiple same column . is it…
0
votes
2 answers

Performance Issues with Derived Table in SQL

I am having trouble using a derived table in MySQL. Does using a derived table inherently slow down the processing of a query? Here is the query I am trying to run. It won't execute and just times out. It does succeed. Really, I have isolated the…
Spencer
  • 21,348
  • 34
  • 85
  • 121
0
votes
1 answer

How to support relative date parameters in Web Intelligence Report

We have a number of Crystal Reports 2011 reports that are currently automatically executed and exported by a custom .Net Winforms scheduling application. These reports all use SQL Commands with hand-crafted SQL to get the best performance against a…
Jools
  • 152
  • 2
  • 11
0
votes
0 answers

MySQL Using Derived Tables WITHIN subQueries without re-defining them

I have a system that generates a SQL query with lots of derived table within sub queries. Here is a typical example: SELECT COUNT(`temp_table_main`.`person_id`) AS "resp_count", `temp_table_main`.`SAMPLE`, SUM(`temp_table_main`.`WT`)…
0
votes
1 answer

TSQL - Issues and errors using a function as a derived table

I am having a difficult time fulfilling a business requirement the way I want to. I am open to suggestions to do this different ways as well. Essentially, there are quite a few data entry errors in the context of Employee and Dependent addresses.…
Jeff.Clark
  • 599
  • 1
  • 5
  • 27
0
votes
0 answers

Teradata - Derived table

The below query consumes more than 1 TB of spool space as the Col11 column has more than 5 million values. SELECT A.COL1, B.COL2, FROM TAB1 A JOIN TAB2 B ON B.COL2= A.COL3 AND B.COL4= A.COL4 AND B.COL6= 'XYZ' JOIN TAB3 D ON D.COL5= A.COL5 AND…
madsthiru
  • 51
  • 2
  • 10
0
votes
1 answer

MySQL Derived Table Issue

I'd like to be able to output the following fields from the query below: AddedById,AddedByName,HoursWorked,CurrentYearlyFlexiAvailable However where I have WHERE addedby=1, I'd like to replace this with the field name AddedById as I do not want to…
Martin
  • 240
  • 4
  • 13
0
votes
1 answer

AdventureWorks2014 - Create an extract of latest hires based upon Job title

I was wondering if anyone could help. I am trying to write some code that returns a list of the latest hires based upon Jobtitle using the Adventureworks2012 databse. So far, I have the following: SELECT DISTINCT HREDH.BusinessEntityID, …
Rosscoasks
  • 97
  • 9
0
votes
2 answers

SQL - Joining 2 derived tables

I have 2 queries that each return fairly complex tables derived from data in a bunch of other tables, and I would like to join them together and then use a group by on the super-joined table. I don't think I can derive this table with a single…
user37745
  • 1
  • 1
0
votes
0 answers

derived table in Hibernate native query

I have a native MySQL query with several join tables, including a derived table and Hibernate is failing to parse it. SELECT