Skip to content

Instantly share code, notes, and snippets.

@billy-bacon
Created November 26, 2013 23:16
Show Gist options
  • Save billy-bacon/7668032 to your computer and use it in GitHub Desktop.
Save billy-bacon/7668032 to your computer and use it in GitHub Desktop.
<select id="getRemainingBorrowsForMonth" resultType="java.lang.Integer">
select
(
select circsPerPatronMonth
from Account
where libraryId = (select libraryId from Patron where id=#{value})
)
-
(
select count(*)
from Circ
where patronId=#{value}
date_trunc('month', borrowed) = date_trunc('month',now())
and date_trunc('year', borrowed) = date_trunc('year',now())
)
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment