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 |
sivakrishna546
Starting Member
1 Post |
Posted - 2011-10-08 : 17:04:47
|
Hi Guys, I have a requirement. Data in the table is as follows.col1 col2 TRNSCTN_CD LOAD_LOG_KEY2324 22345 I 14000011435 23145 I 14000011324 11235 I 14000011232 12324 U 15000011253 23132 I 15000014254 90034 I 1500001 8764 29405 I 1600001 I need output like : 1400001 3 /*(count of 1400001)*/ 1500001 6 /*(count of 1400001 + 1500001)*/ 1600001 7 /*(count of 1400001+1500001+1600001)*/I'm using group by but getting the count for only particular load_log_key count. Could any one please throw somelight on this problem.Thanks in AdvanceSiva Krishna |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-09 : 12:58:06
|
[code]SELECT LOAD_LOG_KEY,RunCntFROM (SELECT DISTINCT LOAD_LOG_KEY FROM Table) tCROSS APPLY (SELECT COUNT(*) AS RunCnt FROM Table WHERE LOAD_LOG_KEY<= t.LOAD_LOG_KEY) t1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|