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
-1
votes
1 answer

Can in line views in oracle sql contain "not in" clause in the query?

For example select * from t1 inner join (select * from t2 where t2.id not in (select ID from t2 where city="Paris")) I tried searching Google. There a lot of examples but none of them uses not in. Plus there are no restrictions specified for an in…
M.Hamza Ali
  • 103
  • 5
-1
votes
2 answers

How does SELECT TOP with ORDER BY into DERIVED TABLE work in Sybase ASE?

I was wondering how this query is executed: I got the error message "An ORDER BYclause is not allowed in a derived table." same using TOP. NOT WORK: SELECT count(*), sum(a_metric_1), a_fld_1 FROM ( SELECT sales AS…
-1
votes
1 answer

Are there any performance differences between `SELECT` and `FROM` in subquery?

These queries return the same result, which is better performance? Subquery in SELECT SELECT books.id, books.title, (SELECT COUNT(*) FROM subscriptions WHERE books.id = subscriptions.book_id) AS subscription_count, (SELECT COUNT(*)…
akm
  • 65
  • 1
  • 7
-1
votes
2 answers

MySQL derived table with join

In the following query I'm having a problem when it comes to returning the right value for count2. What I need is to get the number of rows from table2 which could easily be done by using a derived table t: SELECT name, (SELECT COUNT(*) FROM…
bikey77
  • 6,384
  • 20
  • 60
  • 86
-1
votes
2 answers

cast exception in SQL Server when querying derived table

While trying to answer another SQL Server question on Stack Overflow I encountered something that does not work as I expected. I am using SQL Server 2008R2, but this is probably not important. I have a simple hypothetical table that has some dates…
laylarenee
  • 3,276
  • 7
  • 32
  • 40
-2
votes
1 answer

ORA-19011 in outer query but not in derive table

Here is the function I am using in the inner query and it executes against the whole data set without error with a group by. RTRIM(XMLAGG(XMLELEMENT(E,LOCATION_CD,';').EXTRACT('//text()')) )AS PRAC_LOC However when I bring it up into the outer…
VLOOKUP
  • 548
  • 4
  • 12
-2
votes
1 answer

The request works on phpadmin but not in my php code

Let me please show an other example ... I can't be able to create this view in php (whereas i can in phpmyadmin) $sql="CREATE VIEW ratings.rtgemissfitch AS SELECT derivedtable. ISIN FROM (SELECT ISIN, MAX(Date_Notation_Emission) FROM…
-3
votes
3 answers

Join data from two tables with distinct to select unique job titles

I have two tables: employees and offices. I want to create a view with all the columns from 'employees', but only two columns of 'offices'. Also, I want to select only employees who have unique job titles. I'm trying to do it with the following…
Alice M.
  • 7
  • 7
1 2 3
12
13