Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created June 8, 2017 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/9fc0c06c8bb6b1a070f7c685ff1051e2 to your computer and use it in GitHub Desktop.
Save jezinka/9fc0c06c8bb6b1a070f7c685ff1051e2 to your computer and use it in GitHub Desktop.
private String getShoppingListQuery(List<Meal> meals) {
StringBuffer sb = new StringBuffer();
sb.append("select name, count(name) 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