Search code examples
sqloracle-databasecommon-table-expressionsqlplussql-view

Unsupported use of with clause


create view Captain_Aragna as (with noCommentedProp as (
   select member as nick, title, director, club
   from Proposals
   minus (
       select nick, title, director, club
       from Comments
   )
), noCommentedNicksWCants as (
   select nick, count(nick) as noCommentedCant
   from noCommentedProp
   group by nick
), usersProposalsWCants as (
   select member as nick, count(member) as proposalsCant
   from Proposals
   group by member
), finalJoin as (
   select *
   from noCommentedNicksWCants
   join usersProposalsWCants
   using (nick)
)select nick, noCommentedCant/proposalsCant*100 as Porcentaje
from finalJoin);

Can someone help me with this error, i done know how to create a view and make a with inside, also when i make this with the view, it selects the clumns


Solution

  • I think that the following syntax could work:

    create view Captain_Aragna as 
    with 
        noCommentedProp as (
           select member as nick, title, director, club
           from Proposals
           minus (
               select nick, title, director, club
               from Comments
           )
        ), 
        noCommentedNicksWCants as (
           select nick, count(nick) as noCommentedCant
           from noCommentedProp
           group by nick
        ), 
        usersProposalsWCants as (
           select member as nick, count(member) as proposalsCant
           from Proposals
           group by member
        ), 
        finalJoin as (
           select *
           from noCommentedNicksWCants
           join usersProposalsWCants
           using (nick)
        )
    select nick, noCommentedCant/proposalsCant*100 as Porcentaje
    from finalJoin