It's also somewhat annoying to work with, since it has a rather draconian set of syntactic rules. But once you get past that, it can be quite a handy tool, especially for encapsulating complex queries ...
Usually databases are treated primarily as fairly dumb data storage systems, but they can be capable of much more. Case in point the PostgreSQL database and its – Ada-based – PL/pgSQL programming ...