Scope in derived tables



This is kind of what I'm trying to do in my MS SQL 2000 query. Should
I be able to reference s1.col1 inside the 2nd derived table?

I'm getting 'Invalid column name col1' and it's coming from the 2nd
derived table (I've commented out other refs to just it to check).

Maybe I need to use a temp table instead.


SELECT s1.col1,

(SELECT * FROM

(SELECT COUNT(zzz) AS SomeTotal
FROM tab1
WHERE s1.col1 = zzz)) AS RowCount) /* error here */

FROM
(SELECT col1 FROM table) AS s1


Thank you!

.



Relevant Pages

  • Re: Subquery with invalid column name runs
    ... Queries first try to reference the nearest column, ... Scoping rules in SQL are similar to the scoping rules in block ... But SQL is a bit more complicated. ... If two query expression are on the ...
    (comp.databases.ms-sqlserver)
  • Re: A query that joins 2 tables
    ... halves of the query in the Design Grid, and then copying the text from the ... SQL view of each and pasting either side of the "UNION" operator. ... > SELECT Company, Product, Reference, Price ...
    (microsoft.public.access.queries)
  • Re: QUERY CALCULATION BASED ON DATE RANGE?
    ... Two mistakes/potential problems. ... Access does not always like it when you reference alias's, for purposes of criteria, sorting, etc. it is safest to reference the original field, not the alias. ... I need to modify my SQL Statement to filter out all the records that I ... section....I want this query to only show records that fall within the ...
    (microsoft.public.access.queries)
  • Re: Problem referencing a field in a query
    ... I only see one reference to a table in your SQL statement's FROM clause, ... When I run out of things to tweak/change in a query, ... > I'm not sure what you mean if having included the row source for the chart ...
    (microsoft.public.access.gettingstarted)
  • SELECT Distinct from DataTable, without using SQL
    ... I have the following query I run using SQL: ... group by col1, col2 ... Does anyone know of an XPath query that could do this, ...
    (microsoft.public.dotnet.framework.adonet)