tsql - T-SQL Group by / Order by + SQL Server Reporting Service Parameters -


select     users.userid    ,users.firstname + ' ' + users.lastname    ,[month]    ,[day]    ,x.[przych]    ,x.[wych]    ,x.[przych] + [wych] [ogół]    (select        caseactionhistory.userid        ,month(caseactionhistory.dateadded) [month]        ,day(caseactionhistory.dateadded) [day]        ,sum(case when caseactionhistory.caseactiondefinitionid in (14,15,16) 1 else 0 end) [przych]       ,sum(case when caseactionhistory.caseactiondefinitionid in (20,21,22,23,26) 1 else 0 end) [wych]     caseactionhistory     caseactionhistory.caseactiondefinitionid in (14,15,16,20,21,22,23,26)     group month(caseactionhistory.dateadded),day(caseactionhistory.dateadded), caseactionhistory.userid     order month(caseactionhistory.dateadded) desc,day(caseactionhistory.dateadded) desc offset 0 rows ) x inner join users on x.userid = users.userid 

i'm trying run out out of this. problem is: results of such query displayed this:

user    month    day    x user1     7       31    6 user2     7       31    7 user3     7       31    9 user1     7       30    8 user2     7       30    7 user3     7       30    8  user4     7       31    10 user5     7       31    20 user6     7       31    23 user4     7       30    5 user5     7       30    7 user6     7       30    65 

so in fact few users grouped small groups displayed first, 2nd group, etc. suppose there's problem either group or order by.

as addition i'd ask question concerning parameters in sql server. out of code below i'd set 3 parameters:

user month day 

but problem when set details of parameter , run values multiplied. same user multiplied few times, same month, same day etc. report not reacting on kind of change within parameters.


the main idea of report show number of phone calls done every employee, each day, every month , able compare results others.

calls splitted into: outgoing , incoming. after every phone call employee adds system information regarding phone call , managed during phone call.

so in fact working on 2 tables in case:

caseactionhistory , users

so plan show number of phone calls (incoming, outgoing , sum of those) every day every person.

since caseactionhistory table consits id of user done action , i'd show person's name (which placed in users table obviously).

the problem report should show around 20 users 1 one, 31st of june 20 users 1 one, 30th 20 users 1 one etc, shows 5 users 31st, same users 30th, next 5 users 31st etc (link image showing situation below)

http://img801.imageshack.us/img801/2088/7blu.png

columns are:

userid (to replaced username) day month incming outgoing sum

the rows on bottom 31st july should on top of list not.

welcome stack overflow. few things:

  1. if data 'multiplying' may 'distinct' in main select statement , determine if not dataset repeating?
  2. how applying parameters? should predicates , have nothing groupings except indirectly. may limit set parameter not affect grouping directly, speaking.
  3. what want group by? year, month, (detail)?

ssrs starts out data connection (data source). apply data set query or proc. have query. can apply predicate main dataset 'where user = @user' or 'where user in (@user)'. parameter automatically created if in dataset first '@(something)' creating text parameter of said name. see built in fields, parameters, images, data sources, datasets in 'report data' view use in ssrs creation 'business intelligence development studio'.

so simple example want add group day '(details)' row. if create 'table' element 'toolbox' have single row called details. fill x value , user. in 'design' surface @ bottom see 'row groups'. right click on 'details' row , choose add parent group. group 'day' check 'add group header'. have row grouping day. can repeat process on newly created group group 'month' , , on.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -