Return selected rows and columns from a table

Below, square brackets mark optional elements.

exec [distinct] ps [by pb] from texp [where pw]