Showing posts with label thus. Show all posts
Showing posts with label thus. Show all posts

Friday, March 30, 2012

Need to count and group in units of ten

ok
well this seems easy enough so here it is.
I have a list of some 131500 records with 98 distinct employees thus there are several thousand records per employee. I am using reporting services and I need to set up the graph in units of ten. Having 98 employees on one graph will not work so I need to break them up in units of ten. I can't seem to remember the sql I need to write to accomplish this

any thoughts?
km

Assuming you are using sql server 2005, Can you try using

row_number() over (order by employee_id) as EmpIndex

for getting unique IDs and then split them based on EmpIndex/10=1, ...=9 etc.

|||

I 'think' that it would be far easier to help you if you could provide the table DDL, some sample data in the form of INSERT statements, and a display of your desired results.

For help with that, check:http://www.aspfaq.com/5006

|||thanks for the quick response-- here is some of the sql I have been playing with

SELECT
PH_ado_dac_no as DacNumber,
PH_ado_bimon as BillMonth,
PH_ado_biyr as BillYear,
[GH2_GroupName_(_ado_Bill_seq_no_)]as BillSeqNumber,
[PH_GroupName_(_ado_subscriber_no_)],
GH3_ado_unt as Unt_Employee,
DE_ado_CHANNEL_SEIZURE_DT as ChannelSeizureDate,
DE_ado_tim as ChannelSeizureTime,
DE_ado_CALL_TO_CITY_DESC as Call_To_City,
DE_ado_CALL_TO_STATE_CODE as Call_To_State,
DE_ado_tn as Number_To_From,
DE_checkserv AS CallDurationMinSec,
ROW_NUMBER() OVER(ORDER BY GH3_ado_unt ASC)/10 AS 'groupID',
DE_ado_at_charge_amt as Usage_At_Charge_Amt,
DE_ado_toll_charge_amt AS LongDistance_Toll_Charge_Amt,
DE_ado_tot as Total,
GF3_checkservtot as TotalCheckServe,
GF3_Total as TotalMins,
GF3_ac as TotalLongDistanceCharge
FROM
[cdtable1]

GROUP BY
PH_ado_dac_no,
'groupID'

this looks like something I have been trying to use but does not give the desired results since there may be hundreds of entries within the dataset with the same emp_id. when I use row_number() over (order by employee_id) as EmpIndex /10, the same person has multiple EmpIndex's-- I need each employee to have one and only one EmpIndex and group those in units of ten.
thanks again
km

|||thanks for the response-- I posted some additional information to the post previous to yours

km
|||

I should have mentioned this, sorry, can you add partition by inside the Over() clause.

row_number() over ( partition by employee_id order by employee_id)

|||Great this is looking much better
appreciate your help :-)
km