If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Parameter input through a subquery

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-07, 16:23
dsmbwoy dsmbwoy is offline
Registered User
 
Join Date: Nov 2005
Posts: 91
Parameter input through a subquery

Can someone please help me out. I am trying to create a Microsoft SQL query for an excel report that gets its parameter through a subquery. I keep getting the following error however 'Parameters not allowed in queries that can't be displayed graphically.'

Below is my SQL query that has been simplified. Can someone please show me what I am doing wrong.

select * from report where column_A is in
(select column_A from
from report
where (column_B = ?) and (column_C = 1))


Thanks
Reply With Quote
  #2 (permalink)  
Old 04-05-07, 17:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
try this --
Code:
select distinct foo.* 
  from report as foo
inner
  join report as bar
    on bar.column_A = foo.column_A 
   and bar.column_B = ?
   and bar.column_C = 1
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-09-07, 02:30
dsmbwoy dsmbwoy is offline
Registered User
 
Join Date: Nov 2005
Posts: 91
Thanks for the try but I still get the same error 'Parameters not allowed in queries that can't be displayed graphically.'
Reply With Quote
  #4 (permalink)  
Old 04-10-07, 15:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The query above is regular SQL and works fine on standard-compliant systems. So you may want to ask your question in a SQL Server specific group - not in a group for SQL questions.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-10-07, 15:22
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
change the first AND to WHERE and try it again

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 04-11-07, 04:55
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
Looking at your original post I would say it looks like you are trying to do a select of a select (which is possible in MySQL, however i'm not so sure for MSSQL).
My solution would be :
Code:
SELECT * FROM
  (
   SELECT column_A
   FROM report
   WHERE (column_B = ?) 
   AND (column_C = 1)
  )
However I would say what's the different between that and this :
Code:
SELECT column_A
FROM report
WHERE (column_B = ?) 
AND (column_C = 1)
I think i'm missing something here, because it looks to me like you're getting the same data twice just by joining the table to itself on column_A???
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On