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
2
votes
0 answers

Does a derived query in the FROM statement use criteria from the join?

I have a table of "encounters" with a unique ID and date, and a table of addendums which contain the same IDs and multiple update dates. Given a set of encounters that I specify, I need to know the last time it was updated. My current query looks…
Aww_Geez
  • 148
  • 5
2
votes
0 answers

FULLTEXT operations on a derived table

In my SQL Server 2008 RC2 database I have a table T that has a full text index defined on column FT. I am trying to derive a table containing column FT, then select from this derived table using a full text operation as follows: SELECT ft_alias…
Mike Chamberlain
  • 39,692
  • 27
  • 110
  • 158
2
votes
1 answer

Teradata Volatile table generated from select . How to get a Not Null datatype in there

I prolly think - I am hoping against hope. But I am wanted to see if there's a glimmer here .... When you create a VT like this create multiset volatile table VT , no fallback,no log as ( sel A.1, B.2 from A Join B on ) with…
user1874594
  • 2,277
  • 1
  • 25
  • 49
2
votes
1 answer

Error creating temp table

I am attempting to create a temp table CREATE TEMPORARY TABLE `test_table` ( `test` DATE NOT NULL ); Even if i try other schemas i get the following error Can't create table 'db.test_table' (errno: -1) I tried to google -1 error with no luck.
c3cris
  • 1,276
  • 2
  • 15
  • 37
2
votes
2 answers

How to use aliases in mysql functions

How do i use aliases with spaces in mathematical functions and group by statements. I am able to use it if I use single word aliases, but is there any way of achieving it if the name has spaces ? select count(date_format(start_date, '%W')) AS…
Adarsh
  • 3,613
  • 2
  • 21
  • 37
2
votes
5 answers

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to many): PatientId MeasurementId Recorded …
craig
  • 25,664
  • 27
  • 119
  • 205
2
votes
1 answer

Exclude results from first table in stored procedure with union and derived alias table

I have a stored procedure with a union and derived table situation. The stored procedure basically needs to return all Cases rows where Cases.AssnKey = AssnCtrl.pKey, including ones that don't meet the criteria in the first table (hence the second).…
Mike
  • 417
  • 7
  • 28
1
vote
1 answer

Display multiple categories for single entry

I have the following tables: Category table which has an ID column, a description column, and category parent ID columns as follows: cat_id | cat_description | cat_pid -------+-----------------+-------- 1 | State | 0 2 | Texas…
user979353
  • 13
  • 2
1
vote
2 answers

Oracle SQL query is working by itself, but failing when wrapped into "select count(*) from ()"

I have the following example of the Oracle SQL query which is failing with “ORA-00979: not a GROUP BY expression”. If remove the “select count(*) from (...)” wrapper the query works as expected. The idea is to get the count of rows returned by the…
1
vote
1 answer

Using Recursive CTEs in Power BI

Power BI has some limitations on Direct queries that has proved a hurdle for me to work around; when using direct Query Power BI takes any query that you input and adds a Select * From( statement to the beginning of the code, which prevents the…
1
vote
2 answers

LATERAL syntax in MySQL - Is it just to say that "the left table" is executed first so that the next one can reference it?

What does "A derived table cannot contain references to other tables of the same SELECT" mean? I looked it up in the MySQL documentation SELECT salesperson.name, max_sale.amount, max_sale_customer.customer_name FROM salesperson, --…
user19404608
1
vote
1 answer

Derived table not recognised in where command

I am new and still learning so please excuse my codes. I have googled and as last resort posting for help. Hope one of the senior programmers can help. What I am trying to achieve: which course has below average number of students? I am using SQL…
1
vote
1 answer

Nested Subquery vs Derived table

I'm learning SQL Server and have a question between nested Subquery vs Derived table using from clause. Example for nested Subquery where it is using the from clause. Example was taken from the link :…
1
vote
2 answers

Having Trouble with Sub-Queries

Here is the question to the problem: "FR3.Q7: All views (all columns) that took place after October 15th, by Kindle devices, hosted by Yelp from cities where there are more than 10 clients. Also add the name of the client (as a first column) and…
1
vote
1 answer

Query with multiple fields of a derived table

I have the following tables: CREATE TABLE IF NOT EXISTS "walks" ( id varchar(36), PRIMARY KEY (id) ); CREATE TABLE IF NOT EXISTS "points" ( id varchar(36), time timestamp(6) with time zone, geometry …
robbieperry22
  • 1,753
  • 1
  • 18
  • 49
1 2
3
12 13