Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. select "fullname", coalesce("Action", 0) as "Action", coalesce("Animation",0) as "Animation", coalesce("Children" ,0) as "Children", coalesce("Classics" ,0) as "Classics", coalesce("Comedy" ,0) as "Comedy", coalesce("Documentary" ,0) as "Documentary", coalesce("Drama" ,0) as "Drama", coalesce("Family" ,0) as "Family", coalesce("Foreign" ,0) as "Foreign", coalesce("Games" ,0) as "Games", coalesce("Horror" ,0) as "Horror", coalesce("Music" ,0) as "Music", coalesce("New" ,0) as "New", coalesce("Sci-Fi" ,0) as "Sci-Fi", coalesce("Sports" ,0) as "Sports", coalesce("Travel" ,0) as "Travel"
  2. from crosstab
  3. ('select concat(a.first_name, '' '', last_name) as "fullname", c.name as "category", count(*)
  4. from actor a,
  5. film f,
  6. film_actor fa,
  7. film_category fc,
  8. category c
  9. where a.actor_id = fa.actor_id
  10. and f.film_id = fa.film_id
  11. and f.film_id = fc.film_id
  12. and fc.category_id = c.category_id
  13. group by a.actor_id, category
  14. order by last_name, first_name, category', 'select distinct "name"
  15. from category
  16. order by 1')
  17. as tablename(fullname text, "Action" integer, "Animation" integer, "Children" integer, "Classics" integer, "Comedy" integer, "Documentary" integer, "Drama" integer, "Family" integer, "Foreign" integer, "Games" integer, "Horror" integer, "Music" integer, "New" integer, "Sci-Fi" integer, "Sports" integer, "Travel" integer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement