0

I do not want to create two separate views.

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);

How can I write it in a single query to create view?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
Fam Khan
  • 51
  • 1
  • 3

1 Answers1

1

How about this instead?

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
 );
p.campbell
  • 98,673
  • 67
  • 256
  • 322