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 |
|
stsql
Starting Member
19 Posts |
Posted - 2006-04-14 : 07:42:56
|
| Hi all,I would like to merge fields within this table:create table eventViews(viewID int,eventID varchar,active varchar,DateAdded datetime,views int,clientviews int)I would like to combine all fields where the dateadded is the same day and the eventid is the same. In doing so I would like to total all views that are in the fields that are to be merged and add those to the new view row.Any ideas how to approach this? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
stsql
Starting Member
19 Posts |
Posted - 2006-04-14 : 08:03:43
|
| Hi madhivanan,I don't think thats what I'm looking for, but I'm no expert.Here's some sample data:viewID | eventID | active | DateAdded | views | clientviews |1 | 1 | 1 | 17/01/2006| 1 | 0 |2 | 1 | 1 | 18/01/2006| 3 | 0 |3 | 2 | 1 | 19/01/2006| 1 | 0 |4 | 1 | 1 | 18/01/2006| 2 | 0 |Would give:viewID | eventID | active | DateAdded | views | clientviews |1 | 1 | 1 | 17/01/2006| 1 | 0 |2 | 1 | 1 | 18/01/2006| 5 | 0 |3 | 2 | 1 | 19/01/2006| 1 | 0 |NB. viewid is just the primary key and values to me aren't important.Thanks,R |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-04-14 : 08:13:20
|
[code]select eventID, active, DateAdded, sum(views), sum(clientviews)from eventViewsgroup by eventID, active, DateAdded[/code] KH |
 |
|
|
stsql
Starting Member
19 Posts |
Posted - 2006-04-14 : 09:13:40
|
| Thanks khtan.Richard |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|