Announcement Announcement Module
Collapse
No announcement yet.
IF / CASE statement in criteria Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IF / CASE statement in criteria

    I'm a newbie in Grails, and I have a big problem. I have this domain:

    class Product{

    String name
    Integer priority
    Double quantity
    }

    I want to sort Products by priority (which IS 0 or 1) - desc, and then sort by quantity. In mysql I do it like this:

    select name, IF(quantity>=1,1,0) as q from product
    where ...
    order by priority desc, q desc, id desc

    There is also CASE statement in mysql, but in Grails I don't have an idea how to create criteria for this.

    Thanks in advance!
Working...
X