Query Quiz

Results 1 to 2 of 2

Thread: Query Quiz

  1. #1
    Join Date
    Dec 1969

    Default Query Quiz

    Can someone help me with this query?<BR><BR>For the following data:<BR><BR>Person Team<BR>Jason NEHS<BR>Ryan NEHS<BR>Meghann NEHS<BR>Amber AppleBrook<BR>Brad AppleBrook<BR>Chad Henry<BR><BR>I want the following output:<BR>Person Team TeamCount<BR>Jason NEHS 3<BR>Ryan NEHS 3<BR>Meghann NEHS 3<BR>Amber AppleBrook 2<BR>Brad AppleBrook 2<BR>Chad Henry 1<BR><BR>Thanks,<BR>clkou75

  2. #2
    Join Date
    Dec 1969

    Default Sql Server Solution

    This will get your results:<BR><BR>select a.person, a.Team, teamCount = (Select count(*) from yourTable where team = a.team) <BR>from yourTable a<BR><BR>This doesn&#039;t return the exact same result set, but could be fun to use Rollup?<BR><BR>select a.Team, IsNull(a.person,&#039;teamTotal&#039;) as &#039;Person&#039;, Sum(1) as &#039;teamCount&#039;<BR>from yourTable a<BR>Group by team, person With Rollup<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts