Use fragment or check out my ecto_function (which is fancy way to use fragment).
fragment
ecto_function