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 |
|
tamancha.1
Starting Member
37 Posts |
Posted - 2010-04-02 : 17:14:46
|
| Input:user_id creative196450 A196450 B196450 C243011 B243011 A245789 A245789 AOutPut:user_id creative (no of times same user_id) (Distinct (creative))196450 A 3 3196450 B 3 3196450 C 3 3243011 B 2 2243011 A 2 2245789 A 2 1245789 A 2 1 |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-04-03 : 01:58:52
|
| See This Thread.http://visakhm.blogspot.com/search/label/apply%20operator%20sql%202008 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-03 : 02:02:50
|
| [code]SELECT t.user_id,t.creative,t1.CntUser,t1.CreativeCntFROM YourTable tINNER JOIN (SELECT user_id,COUNT(*) AS CntUser,COUNT(DISTINCT creative) AS CreativeCnt FROM YourTable GROUP BY user_id)t1ON t1.user_id = t.user_id[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|