Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Jonathan0624
Starting Member
2 Posts |
Posted - 2011-01-12 : 12:34:13
|
| Hello Everyone. I've been wrestling with my head in order to try to get some data outputed the way I need it, but I just can't get it right. I'm not a database guru, so please forgive me if I use the wrong terminology.I have two tables; USERS and ISSUES, and I am trying to output the total number of issues entered by 5 specific users in this format:Users TotalIssues------------------BSmith 30JDoe 45KGarnet 22MJordan 23JStarks 3The users table contains more than 1,000 users, and the issues table contains more that 40,000 entries.Here is some info on the two tables:The users table contains the following columns (i've also put in some sample data):USERNUMBER, USERID------------------1 MJordan2 KGarnett3 JStarksThe Issues Table contains the following columns (i've also put in some sample data):IssueNumber, EnteredBy----------------------234 MJordan776 JStark7763 JonJonBoth UserID.Users and ISSUES.EnteredBy are identical.How would I go about getting the total number of issues entered by 5 specific people in this format:Users TotalIssues------------------BSmith 30JDoe 45KGarnet 22MJordan 23JStarks 3Thanks for your help! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 12:38:48
|
| [code]SELECT u.Userid, COUNT(IssueNumber) AS TotalIssuesFROM Users uINNER JOIN Issues iON i.EnteredBy = u.UserIDWHERE u.UserID IN ('BSmith','JDoe','KGarnet','MJordan','JStarks')GROUP BY u.Userid[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Jonathan0624
Starting Member
2 Posts |
Posted - 2011-01-12 : 12:53:53
|
| Thank you so much. That produced the exact results that I was seeking. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 12:55:28
|
wc ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|