Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Subquery

Author  Topic 

eilob
Starting Member

6 Posts

Posted - 2008-04-22 : 12:09:11
Hi all,

I have a problem with a subquery, trying to get a Fusion chart working in Visual Studio, but when i run it I get an error in the SQL query:

The column prefix 'd' does not match with a table name or alias name used in the query.
The column prefix 'd' does not match with a table name or alias name used


sql1 = "Select (d.WeekofYr),"

+ "(select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='1 Jan 2008') AS Week1,"

+ " (select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='7 Jan 2008') AS Week2,"

+ " (select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='14 Jan 2008') AS Week3,"

+ " (select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='21 Jan 2008') AS Week4,"

+ " (select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='28 Jan 2008') AS Week5,"

+ " (select PSC_Approved, Field_Approved, All_Requests from Bid_Desk_France_Cumulative_Margin_Approved where d.WeekOfYr='4 Feb 2008') AS Week6"

+ " from Bid_Desk_France_Cumulative_Margin_Approved";

Thks & regards

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-22 : 12:51:32
Try deleting the "d." bits of your query.

Whether that works or not, you should post your table structure, a few rows of sample data and the output you would want for that sample data. Your query can be improved hugely...


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

eilob
Starting Member

6 Posts

Posted - 2008-04-25 : 05:07:50
Hi This is my table structure:

WeekofYr PSC_Approved Field_Approved All_Requests
07/04/2008 50 60 45
14/04/2008 48 36 50
21/04/2008 29 45 28
28/04/2008 36 41 42

Thks & Rgds
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-25 : 06:03:58
Duplicate post.
Started here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=101505



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -