|
-
January 21st, 2008, 04:53 AM
#1
Problem with a query
Hi everyone! I'm getting an error with this query:
Code:
select * from
(
select
avg(esiti.num_record) as media, count(*) as num_esiti
from
c_esiti esiti
inner join
(
select
distinct dt_rif
from
c_esiti es
where
es.r_id_controllo = @id
and es.fl_successo = 1
and es.dt_rif <>
(
select max(esi.dt_rif) from c_esiti esi
where esi.fl_successo = 1 and esi.r_id_controllo = @id
)
) esiti_ok
on
esiti.dt_rif = esiti_ok.dt_rif
and esiti.dt_elab =
(
select
max(dt_elab)
from
c_esiti e
where
e.dt_rif = esiti_ok.dt_rif
)
) esiti_precedenti
The funny thing is that the inner query (the one that produces "esiti_precedenti") works fine, but when I try to use it as a subquery I get "Internal SQL Server Error". The query produces a single row with an average and a count; I would need to append these two values to a row I get from another query, so my approach was to join them "on 1=1". Can you suggest an alternate way of doing it?
I'm using SQL Server 2000 in Query Analyzer.
I owe Paul McKenzie a pizza.
I am no expert; but they say I can make concepts easy to understand. That's why newbies questions are mine!!! XD
-
January 21st, 2008, 05:27 AM
#2
Re: Problem with a query
Nevermind, I found it myself. It seems there's a known problem with SQL Server 2000 (pre-SP1), where a subquery with computed or aggregate columns causes this error.
I owe Paul McKenzie a pizza.
I am no expert; but they say I can make concepts easy to understand. That's why newbies questions are mine!!! XD
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|