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 |
|
davek
Starting Member
1 Post |
Posted - 2002-09-22 : 15:11:00
|
| Need help just want to create a update statement.this is what I have now!select useremail, time_dimension.quarter, time_dimension.the_yearFROM users INNER JOIN time_dimension ON TimeID = time_dimension.time_idGROUP BY time_dimension.quarter, time_dimension.the_year, useremailHAVING COUNT(useremail) <= 5 AND time_dimension.quarter = 'q2' AND time_dimension.the_year = @yrORDER BY time_dimension.the_year, time_dimension.quarter update uniqueUsers set onetofive=@@rowcount,quarter='q2',year=@yrwhere quarter='q2'and year=@yr |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-09-24 : 11:22:15
|
| post sample input data and sample expected results.....make up the values if needs be (but make sure your displayed data works properly in relation to what you are asking)....it'll help use understand more your problem...and thus...maybe...help you faster. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-09-24 : 11:49:24
|
| Try describing what you want as well as posting code - what you have there doesn't give much away.@@rowcount will be a single number - I'm guessing that is irrelevantI'm guessing you want to update uniqueUsers with the number of emails for the user for all those with less than 5 in that period (or ever?)?something likeupdate uniqueUsersset onetofive = (select count(*) from users INNER JOIN time_dimension ON TimeID = time_dimension.time_id where users.id = uniqueUsers.user_id AND time_dimension.quarter = 'q2' AND time_dimension.the_year = @yr )where 5 >= (select count(*) from users INNER JOIN time_dimension ON TimeID = time_dimension.time_id where users.id = uniqueUsers.user_id AND time_dimension.quarter = 'q2' AND time_dimension.the_year = @yr )==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|