473,657 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!

Jun 29 '07 #1
1 3107
Stephen2 (St*****@mailin ator.com) writes:
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
Yes, you should be able to, and in SQL 2005 you are. But in SQL 2000 there
is a bug that gets in the way. It seems that you will have to resort to
a temp table.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4918
by: bardos | last post by:
Hello, I'm relatively new to C++ so I hope you can help clear up a problem. You may well be able to do so before checking the example, so don't be put off by the long post :) The problem regards the usage and effect of the :: scope qualifier. I'm converting a Java app to C++ and need to find the equivalent of using the Java 'super' keyword. This executes the 'superclass's constructor (with possibly different arguments from the derived...
3
4407
by: richard pickworth | last post by:
Hello :) I am familiar with using scope resolution operator to define classes, but why does it turn up elsewhere? thanks richard
1
2015
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to dataset dsSearch CODE ON http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3994&lngWId=10 using SQL connection get data from view on sql server, add to dataset dsSearch
1
2169
by: Chris Dunaway | last post by:
I use the class below as a base class to make object that execute in their own thread. If I create a derived class and instantiate an instance of that class, what happens to the thread if the instance goes out of scope? Will the thread continue to run? Does the thread run independently of the object? Does the thread keep the object alive even though my reference to it goes out of scope? Public MustInherit Class ThreadWrapper 'Our...
1
2590
by: Ruediger Herrmann | last post by:
Hello again, as I am new to PostgreSQL (great pice of softwork btw) this probably won't be the last question. I access PostgreSQL from Java via the PostgreSQL JDBC driver. I am currently building a little framework that provides basic CRUD operations by mapping class properties to database columns. All my primary keys are artificial and built by sequences (datat type bigserial). Now I need to (re-)read the row that was...
9
1878
by: olanglois | last post by:
Hi, I am not sure if I have found a compiler bug (I am using VC++.NET2003) or if this is the correct behavior defined by the language but I am sure someone can clear up my confusion. Suppose the following: class Base { protected: int x;
8
2797
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table, I have a where clause which states : where PermitID like @WorkType order by WorkStart DESC
1
1115
by: sasha | last post by:
class Base{ public: std::ostream& operator<<( std::ostream& os, const string &str ) { return print(os); } void print(std:ostream& os){ os<<"Base\n";} };
6
8152
by: Bhawna | last post by:
I am into c++ code maintenance for last 3-4 years but recently I am put into design phase of a new project. Being a small comapany I dont have enough guidance from seniors. Currently I am into a situation where I am implementing base class functions by including a pointer to subclass member in base class. Reason being functionality is common for subclasses but the members are common within subclass only (static member of subclass) but...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.