Posts

Showing posts from January 15, 2019

How to group by two columns?

How to group by two columns? Please consider below. I wish to list the number of times that each users made reservations for a conference room, and how many different rooms he/she used: room user ---------- 1 1 2 1 3 2 4 3 4 3 Desired output: user reservations rooms ------------------------- 1 2 2 2 1 1 3 2 1 Can anyone tell me how to do this? I now have: select [user], count(1) from [table] group by [user] But this doesn't give me the rooms count. Adding another count() doesn't work. count() Without posting actual Schema we can't actually help - Is the table rooms or Reservations? – Dawood Awan Sep 6 '18 at 15:03 2 Answers 2 you need a count ( distinct <column> ) for the room count ( distinct <column> ) select [user], count(*) as reservations, count(distinct room) as rooms from [table] group by [user] Use aggregation with distinct for room Select user, count(*) reservation_ numbr,count(distinct room) as rooms from t group by user Th

Plausible reason for a civilization to not explore their own planet and explore space instead

Image
5 $begingroup$ A civilization of land-living humanoids occupies a patch of land on a continent (patch of land size: a few US States, let's say Montanas) and, without even exploring the continent fully, develops space travel and starts to explore space. Their home planet is similar to Earth, fully habitable, with a number of continents, oceans, etc. There are other races on the planet, some of them have civilizations, but they are much more primitive. What I need is a reason, why exactly would they not explore their own homeworld, rather choosing to expand in space? space-colonization civilization share | improve this question edited Aug 25 '18 at 20:51 Brythan 20.3k 7 42 83 asked Aug 25 '18 at 10:36 Mranderson Mranderson 404 2 11 $endgroup$ $begingroup$ What do you mean by "races"? Why don't you just make those other "races" hostile? In a way, we don't explore certain areas becau