0
큰 쿼리 내에서 다음 하위 쿼리가 있습니다. "하위 쿼리가 1 개 이상의 값을 반환했습니다."라는 오류가 나타납니다. 이 문제를 어떻게 해결할 수 있을지 모르겠지만 두 쿼리의 결과를 나누는 일은 여전히 있습니다. SQL Server 2005를 사용하고 있습니다.하위 쿼리가 두 개 이상의 값 오류를 반환했습니다.
감사합니다.
SELECT
sample_fields, -- some fields here
(SELECT
c1/c2 AS department_occupancy_rate -- doing division of results of both queries
FROM
property as c
JOIN (
SELECT store_id, cast(count(*) as decimal(10,2)) AS c1
FROM property
WHERE
non_ha =1
AND property_type LIKE '%587%'
GROUP BY store_id
) AS sub1
ON c.store_id = sub1.store_id
JOIN (
SELECT store_id, cast(count(*) as decimal(10,2)) AS c2
FROM property
WHERE
property_type LIKE '%587%'
GROUP BY store_id
) AS sub2
ON c.store_id = sub2.store_id
) as results,
FROM
sample_table -- a table here
INNER JOIN sample_table1
ON sample_table2 -- joining here
GROUP BY sample_field -- grouping
SQL의 취향에 따라 SELECT TOP 1 또는 SELECT ... LIMIT 1을 시도하십시오. –
SQL을 리팩터링하려고 했습니까? 그것은 꽤 groady ... –
쿼리의 마지막 조인을 확인했습니다 -> INNER JOIN sample_table1 on sample_table2? – Luftwaffe