Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private String getShoppingListQuery(List<Meal> meals) {
StringBuffer sb = new StringBuffer();
sb.append("select no || ' x ' || name from ( select name, count(name) as no from (");
for (int i = 0; i < meals.size(); i++) {
sb.append(getIngredientsQuery());
if (i < meals.size() - 1) {
sb.append(" union all ");
}
}
sb.append(") group by name order by name collate nocase);");
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment