0

我不想创建两个单独的视图。

create view fg_voted as (
  select * 
    from (select f1.foto, count(f1.vote) stars,f1.vote, f1.voted 
            from fg_foto_bewertung f1 
           where f1.vote >= 3 group by f1.foto, f1.vote) vi_foto 
   where stars > 3);

如何在单个查询中编写它来创建视图?

4

1 回答 1

1

这个怎么样?

create view fg_voted as (

  SELECT f1.foto, 
         count(f1.vote) stars,
         f1.vote, 
         f1.voted 
  FROM   fg_foto_bewertung f1 
  WHERE  f1.vote >= 3 
  GROUP BY f1.foto, 
           f1.vote, 
           f1.voted 
  HAVING count(f1.vote) > 3
 );
于 2011-04-26T03:47:10.947 回答