Skip to content
Advertisement

Tag: group-by

How to COUNT “accounts” only if character/user exist

I have 2 tables – “accounts” and “players” I’m using this query to COUNT accounts Accounts table estructure: Players table estructure: * Let’s say the query counts 10 accounts but only 3 accounts have a character/user created. I would like to know how to count only those 3 accounts without taking in consideration how many characters/users has the account, so

Summing condition excludes rows without positive sum

I’m having a weird issue where in returning the sum of rows where a condition is true seems to only return rows if that condition is true – or at least, it is excluding a large majority of the rows that would otherwise be returned. Original query – which returns all rows: For each row that was returned, I also

Optimize SQLite Query using GROUP BY

I am trying to optimize my query which uses GROUP BY. But can’t it takes too long time. I have a virtual table which contains 3 columns: I want the group to be just as the query below, but it just takes a bit too long to run. For example I tried this first which works pretty good but still

Identifying products that a customer owns

I want to check whether my customer owns an iPhone, iPad, or Macbook. I am not looking for how many iPhone or iPad or Macbook one customer has, I just want to identify if they own any of them, or if they own any two, or if they own all three. I am thinking of using the CASE WHEN function

Advertisement