Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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++) {
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