michaelrobertfrench
asked on
t-sql - how to without a cursor implementation
Here is a very straightford sql to get me counts from the group by clause:
select
count(*) col1
from
tsys..tbl_base
group
by
base_month,
base_year
It returns:
col1
238875
239221
239454
239702
239965
240292
240708
241174
241624
241999
242426
Now without using a cursor I want to add a column to the result set to show the change in count.
Can you show me the sql that might accomplish this?
select
count(*) col1
from
tsys..tbl_base
group
by
base_month,
base_year
It returns:
col1
238875
239221
239454
239702
239965
240292
240708
241174
241624
241999
242426
Now without using a cursor I want to add a column to the result set to show the change in count.
Can you show me the sql that might accomplish this?
what version of sql server are you using?
ASKER
sql 2000
ASKER
The result set would look like this:
col1 change_from_prior period
238875
239221 346
239454 233
239702 248
239965 263
240292 327
240708 416
241174 466
241624 450
241999 375
242426 427
The change_from_prior_period is what I need the sql to provide. An easy implementation with a cursor or a while loop but I want sql returning this result set.
col1 change_from_prior period
238875
239221 346
239454 233
239702 248
239965 263
240292 327
240708 416
241174 466
241624 450
241999 375
242426 427
The change_from_prior_period is what I need the sql to provide. An easy implementation with a cursor or a while loop but I want sql returning this result set.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes - Thank You Very Much
Open in new window