1

これが正常に機能する最初のクエリです。

SELECT count(event_log_id) as icount, cast(youth_name as varchar(max)) as yname
FROM CIRComplete
WHERE  actual_date between '2012-01-01' and '2012-04-30'
  AND is_deleted = '0' AND Closed = '1' 
GROUP BY cast(youth_name as varchar(max))

これにより、icount と yname の 2 つの列が得られます。

yname と icount (icount > 1) を取得する 2 番目のクエリを実行したい

私は何時間もこれに取り組んできましたが、ついに助けを求めることにしました。

4

3 に答える 3

1

なぜ 2 番目のクエリを使用するのですか? これは次のことを行う必要があります。

SELECT
   count(event_log_id) as icount ,
   cast(youth_name as varchar(max)) as yname 
   FROM CIRComplete 
   WHERE (actual_date between '2012-01-01' and '2012-04-30') and 
         is_deleted = '0' and Closed = '1' 
   GROUP BY cast(youth_name as varchar(max))
   HAVING count(event_log_id) > 1
于 2012-05-22T17:17:13.397 に答える
0
SELECT  cast(youth_name as varchar(max)) as yname,
        count(event_log_id) as icount
FROM    CIRComplete
WHERE   (actual_date between '2012-01-01' AND '2012-04-30') AND 
        is_deleted = '0' AND 
        Closed = '1' 
GROUP BY cast(youth_name as varchar(max))
HAVING  count(event_log_id) > 1
于 2012-05-22T17:17:54.037 に答える
0
SELECT  
   count(event_log_id) as icount
  ,cast(youth_name as varchar(max)) as yname
FROM
  CIRComplete
WHERE 
   (actual_date between '2012-01-01' and '2012-04-30') and is_deleted = '0' and Closed = '1' 
GROUP BY
   cast(youth_name as varchar(max))
having icount > 1
于 2012-05-22T17:17:59.383 に答える