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 |
|
inrsence
Starting Member
48 Posts |
Posted - 2001-08-30 : 13:26:06
|
| Hello,OK.. I thought I had seen a way to do this somewhere, but I can't find it. Here is my problem.I've got a table storing data. It looks like this:Region varchar(20)Score intAttempts intI want to generate a table that looks like this:Region varchar(20)Total int -- The total tests for the regionLazy int -- The total tests that made 0 attemptsSo I was writing this:CREATE TABLE #Results(Region varchar(20), Total int, Lazy int)INSERT INTO #Results(Region,Total)SELECT Region,Count(*)FROM tableGROUP BY RegionNow I want to update to get the last set of values.. but I'm not sure how to get those. I know that the query that would return the values for Lazy looks like this:SELECT Region,Count(*)FROM tableGROUP BY RegionHAVING SUM(Attempts) = 0How do I combine this with what I have above to perform the update.. I know I can get it with a cursor.. but I would really like to avoid that.Anyone got some helpful advice?Thanks in advance,Greg |
|
|
|
|
|