Skip to content

Instantly share code, notes, and snippets.

@ssx
Last active August 29, 2015 14:07
Show Gist options
  • Save ssx/ddd2f6127c00e18ef38e to your computer and use it in GitHub Desktop.
Save ssx/ddd2f6127c00e18ef38e to your computer and use it in GitHub Desktop.
Answers Needed:
1. What Name generally has the most spaces
2. What time of day is 'name' likely to have spaces
3. What name generally has the least spaces
Date Time Name Spaces
2014-10-01 10:00:00 Item 1 753
2014-10-01 10:00:00 Item 2 436
2014-10-01 10:00:00 Item 3 86
2014-10-01 10:00:00 Item 4 234
2014-10-01 11:00:00 Item 1 323
2014-10-01 11:00:00 Item 2 578
2014-10-01 11:00:00 Item 3 565
2014-10-01 11:00:00 Item 4 654
2014-10-01 12:00:00 Item 1 345
2014-10-01 12:00:00 Item 2 11
2014-10-01 12:00:00 Item 3 121
2014-10-01 12:00:00 Item 4 321
2014-10-01 13:00:00 Item 1 221
2014-10-01 13:00:00 Item 2 4321
2014-10-01 13:00:00 Item 3 421
2014-10-01 13:00:00 Item 4 3
@grumpysi
Copy link

Something like this for most spaces ??

select sum(spaces) from xxx
group by name
order by sum(spaces) desc
limit 1

@grumpysi
Copy link

select time
where name = 'Item 2' and spaces > 0

@grumpysi
Copy link

select name, sum(spaces)
from xxx
group by name
order by sum(spaces) asc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment