473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Generating summary reports from 2 tables with multiple calculations

4
Hi anyone,

I need help here!

Client Table
1. ClientId - Autonumber (Primary Key)
2. Client name - text

Session Table
1. SessionId - Autonumber (Primary Key)
2. sCid - Number (Foreign Key refers to Client.ClientId)
3. SessionType - Text (values = "T1"/"T2"/"T3"/"T4")
4. SessionDuration - number
5. SessionDate - Date

I need to create a report that looks like this

Client Name - T1/duration - T2/duration - T3/duration - T4/duration
client 1
client 2

Basically showing each client and how many sessions and how much time he spent on each session type.
i.e.Count(Sessiontype)/Sum(duration)


Is this even possible? Please enlighten me.
Anyone who has a solution, please help!

Thank you!



Best Regards,
knoty
Jun 15 '12 #1
6 1675
Rabbit
12,516 Expert Mod 8TB
Use a crosstab query.
Jun 15 '12 #2
knoty
4
Thanks Rabbit for the tip,

However, I have not been able to achieve complete results but here is what I got.
I only managed to get this using the Crosstab_wizard

cRegNumber - cName - cPrgmType - SumOfnDuration - FI - IS

2012-06-01 - Gregory - ESU - 2 - 1 - 2

The sql code generated is attached below. Hope you can advice me how to tweak it such that it gives the duration for each session type. [ESU Summary Report] is a Select query to merge the 2 tables that access requires in order to use the crosstab query.

================================================== ======================================
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count([ESU Summary Report].nSessionNo) AS CountOfnSessionNo
  2.  
  3. SELECT [ESU Summary Report].cRegNumber, [ESU Summary Report].cName, [ESU Summary Report].cPrgmType, Sum([ESU Summary Report].nDuration) AS SumOfnDuration
  4.  
  5. FROM [ESU Summary Report]
  6.  
  7. WHERE ((([ESU Summary Report].cPrgmType)="ESU"))
  8.  
  9. GROUP BY [ESU Summary Report].cRegNumber, [ESU Summary Report].cName, [ESU Summary Report].cPrgmType
  10.  
  11. PIVOT [ESU Summary Report].nSessionType
================================================== ======================================


thank you

knoty
Jun 16 '12 #3
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

Why are you transforming on the count when you want the sum of the duration?
Jun 16 '12 #4
knoty
4
Thx Rabbit,

Sorry about the code tags.

I'm not a programmer and I actually don't understand the code very well.
I used the crosstab wizard to generate that code. I fiddled with the wizard but got stuck with the code in my previous post that came closest to what I was looking for.

What I need are 2 calculations as column headers.

1. Sum of Duration for each session type
2. Count of sessions for each session type

These must be in 2 seperate columns x 4 SessionTypes = total 8 columns, Grouped by client name

Apologies for my first post as it was misleading. I need a table with 9 columns which looks like this.

(Client Name) - (T1) - (sumT1duration) - (T2) - (sumT2duration) - (T3) - (sumT3duration) - (T4) - (sumT4duration)

(Client Name) = Name of client
(T1) = Count of T1 Sessions
(sumT1duration) = Sum of duration of T1 Sessions
(T2) = Count of T2 Sessions
(sumT1duration) = Sum of duration of T2 Sessions
(T3) = Count of T3 Sessions
(sumT1duration) = Sum of duration of T3 Sessions
(T4) = Count of T4 Sessions
(sumT1duration) = Sum of duration of T4 Sessions

Thank you for you patience.


Best regards,
knoty
Jun 16 '12 #5
Rabbit
12,516 Expert Mod 8TB
You can't do two calculations in one cross tab. You will have to create two cross tabs and then join them together.
Jun 16 '12 #6
knoty
4
Ok thanks!

Solved!
Jun 17 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raheel Hussain | last post by:
hi, guyz. I want to generate HTML based reports with ASP. But the problem which i m having is to controll the Paging operation while printing the reports. Unlike the Professional reports...
2
by: Sami | last post by:
Could someone explain clearly how to go about doing this? I have tried setting up the structure on numerous occasions, but it never seems to work. Could someone please help me out? Thanks!
6
by: NOSPAMrclark | last post by:
I'm wondering . . . . What is the generally accepted method for calling reports from multiple locations? Example: REPORT-A is called by selecting a record in a listbox and clicking a...
2
by: RSB | last post by:
Hi Everyone , i am working on this Project and we do have a requirement of creating Graphical reports .. like Charts etc. So how do i achive that .. DO we use a third party tool like crystal...
1
by: josecruz | last post by:
I have to create a summary report that will provide counts and # average of days for multiple "Status" by entering different dates for every criteria. I have created several queries that calculates...
3
by: marcpp | last post by:
Hi i'm introducing to do reports from python, any recomendation?
0
by: FMS Development Team | last post by:
Hi Everyone, I just published a paper with a sample database describing how to create a monthly summary report without VBA code. Basically, a financial crosstab showing 12 months of summaries...
6
by: Jason1983 | last post by:
Hi , This is Jason....I am very thankful to this community for helping me couple of times earlier with my issues.... Iam trying to create a Report which is attached to a Form ....On that form i...
2
jinalpatel
by: jinalpatel | last post by:
I have two tables MainFirm Name Address City State Zip County
2
by: veer | last post by:
hi i made program in which i am generating the report of a ms-table database it works fine only on my computer and generatin the reports but when i run this exe on any computer the whole programe...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.