sql - Can a nested Group By be done in a single Select? -


Using T-SQL (we are in 2008, but if it can be done in 2012 using some new functions / extensions, then

It is completely out of curiosity ... I just ended up going through a group with a group going through. But I'm curious to see if there is a way to do this in the Single query, maybe there are some fancy fakirs or extensions I have not yet learned .... This is a challenge from Before that it has already done it, work needs to be done.

I tried to create an example table here, but it is too big to make, so this is the concept. The table has three columns, UserID, Usergroup and minutes. In an hour's increment, we log in to how much time a user spends within an app. For example, for example, spend 15 minutes during the hours of UserID 1 04/28/2014 10:00:00 for 10 minutes and then 04/28/2014 11:00:00 ... and the same Kind. (For this example, please ignore the constraints of any time every day or per month etc.)

I want to see people using Number of users per For at least 30 minutes it was used to argue that:

  Select UserGroupID, COUNT (*) from (Select UserGroupID, UserID Example Group from UserGroupID, UserID passing SUM ([Minutes]) = 30) UserGroup ID by AS X Group  

Is it a The material can be used in the query? I do not see the efficiency here, I'm just curious.

I do not think so, but it is difficult to prove negative.

The following questions (without the without section) can be simplified. So:

GroupCidID, COUNT (*) User user (UserGroupID, usergroup ID, UserID in example group from user group); UserGroupID by ASGroup;

is very similar:

  Select UserGroupId, COUNT (different user id) example group from UserGroupId;  

(These are not exactly equivalent if UserId is NULL , but that case can also be handled.) < / P>

I do not think there is a way to do your full query, though. You will have to collect by UserGroupId, UserId to get the sum () condition. Then you only have to collect by UserGroupId . Nothing comes into mind.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -