MDX Problems With Cumulative Totals Of DistinctCount Measure In Function PeriodsToDat

Mar 26, 2005

Hello Experts,

I have a Problem with cumulative totals of DistinctCount of customers while working in the MDX-Query-Designer of Analysis Services.
The measure [Measures].[DC Customer] is a distinct count of CustomerNr of Customers who have purchased products.
I use

With Member [Measures].[DC Custumer kum] As 'Sum (Periostodate([Time].[Year]),[Measures].[CD Customer kum]'
Select {[Measures].[DC Custumer],[DC Custumer kum]} on colums,
[Productgroup].[Maingroup].members on rows
From Sales
Where [Time].[All_Time].[2005].[March]

but it returns the sum of [Measures].[DC Customer] and added the January, February and March value.
I need to get the value of customers who have purchased products from january to march.

Can anyone help?
Thank you in advance

View 1 Replies


ADVERTISEMENT

Problems With Aggregation Of Distinctcount-measure

Mar 26, 2005

Hi Experts,

I have a problem:
I have various cube packed in a virtual cube to give me distinctCount Values of customers who purchased products (DC customer] and purchased products (DC product) along with Saleries [RW] over numerous dimensions such as productgroups customergroups etc.
In the calculated measure [RW kum] I can sum the the salaries from the beginning of the year until [time].currentmember with the following MDX-Code:
With member [Measures].[RW kum] As 'Sum(Periodstodate([time].[year]).[Measures].[RW])'
Select {[Measures].[RW],[Measures].[RW kum], [Measures].[DC customer]} on rows,
[Productgroup].[Itemgroup].Allmembers on columns
From [vcub_Sales]
Where [Time].[2005].[march]

IF I use this PeriodsToDate-Formular with the the measure DC customer I will get the sum of distinctcounts of the periods.

What I want is the distinct count of all customers who have purchased since the beginning of the Year until the [Time].currentmember in the same Level.

Given this problem, do I..
1. have make another Cube or
2. another time dimension or
3. is there a way in MDX to get the result?

I would appreciate any replies.

Zannadar

View 1 Replies View Related

Trying To Get Daily Totals From Cumulative Totals In A Pivot

Oct 2, 2006

I have been providing sales data for a few months now from a table that is set up like this:

Date WorkDay GasSales EquipmentSales

9/1/2006 1 100.00 200.00

9/4/2006 2 50.00 45.00

etc.

As can be seen, the data is daily, i.e., on the first workday of September we sold one hundred dollars in gas and two hundred dollars in equipment. On the second workday of September we sold fifty dollars in gas and forty-five dollars in equipment.

Now, however, the data I have to pull from is cumulative. So, using the last table as an example it would look like this:

Date_WorkDay_GasSales_EquipmentSales

9/1/2006 1 100.00 200.00

9/4/2006 2 150.00 245.00

etc.

To make things more complicated, the powers that be wanted this data presented in this fashion:

Total Sales:

1_2_etc.

300.00 95.00 etc.

 So, I have been doing a pivot on a CRT to get the data to look like I want. The code is like this:

with SalesCTE (Month, WorkDay, [Total Sales])

as

(

SELECT

datename(month, cag.date),

cag.WorkDay AS [Work Day],

sum(cag.sales_gas + cag.sales_hgs) AS [Total Sales]

FROM CAG INNER JOIN

Branch ON CAG.[Oracle Branch] = Branch.OracleBranch

group by cag.date, cag.WorkDay

)

select * from SalesCTE

pivot

(

sum([Total Sales])

for WorkDay

in ([1],[2],[3],[4],[5],,[7],,[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23])

) as p

So, my question is:

How do I get the data to give back daily totals instead of the cumulative amounts for each workday? If the query was a simple one, I'd do something like

select [1] as [Day 1], [2]-[1] as [Day 2], [3]-[2] as [Day 3], etc.

but the query is far from normal, with the CRT and the pivot. I can't seem to get it to work how I'd like.

Any advice/answers? Thanks in advance!!!

 

P.S. I don't know how to get it to quit with the freakin' smileys.... I suppose you can figure out what my code is really supposed to look like above. Needless to say, it doesn't include a devil face and a damn music note...

View 12 Replies View Related

Carrying Cumulative Totals Over Months

Apr 11, 2008



I am making a report for a car dealer. Each month a certain number of cars will be placed on the lot and a certain number will be taken off. I want to make a report that will show the inventory levels at any point in time. (I will further refine the report by color, origin, model, etc later.) I am currently listing each car in my inventory table, flagging it with a "removed" flag when it is sold. My flag for adding a car is 1 and removing a car is -1. It's easy enough to sum the table and get the current inventory level but I'm having trouble looking back over time.

Say in January I had 35 cars on the lot. I sold 20 and added 5. In February I sold 9 and added 10. In March I sold 12 and added 5.

I need the report to break every month. But on the break I need to add all the cars in the table minus cars sold. For the January report it should show a total (cars added - sold) in the table. Each month I need to take a new grand total of all cars added minus cars sold up to the end of that month OR cars added that month minus cars sold that month added to the running total from the previous month.

Is there some sort of calculate measure I could stick in my cube that would carry these totals? Or any other ideas?

Thanks.

View 1 Replies View Related

Cumulative Totals In Chart : Report Builder

Jan 24, 2007

Hi,

I am trying to display a line chart with cumulative totals over period of 12 months in a fiscal year. I know this can be achieveable in report designer using "Running value function".

Any idea how to achieve the same in Report builder ?

thanks in advance.

Here is the data :

Month Count

July 2

Aug 3

Sept 2



Expected output should be

Month Count

July 2

Aug 5(July count + Aug.Count)

Sept 7(July count + Aug count + Sept Count)

Regards,

bala

View 1 Replies View Related

Transact SQL :: Cumulative Totals - Rolling Window

Aug 14, 2015

I'm trying to generate a cumulative total with a rolling window of 13 time periods..Previously I was able to do left outer join to the same table 13 times to add the quantity field but it appears with the migration to SQL Server 2014, that many left outer joins is not possible (query that would run in 3 mins is taking well over 15 hours now)..

View 7 Replies View Related

Rolling Data In Forecast And Cumulative Totals Question

Oct 12, 2007



I have a result set that looks like this:





Code Block







Quarter

Year

EstimatedValue

ClosePercent

EstimatedCloseDate


4

2007

100000

50

12/31/07 5:00 AM


4

2007

20000

50

11/30/07 5:00 AM


4

2007

20000

90

10/30/07 5:00 AM


1

2008

278000

50

3/31/08 5:00 AM


4

2007

200000

50

11/30/07 5:00 AM


4

2007

225000

90

10/31/07 5:00 AM


4

2007

36500

90

10/31/07 5:00 AM


4

2007

80000

90

10/31/07 5:00 AM


4

2007

107200

90

10/31/07 5:00 AM


4

2007

225000

75

12/31/07 5:00 AM


4

2007

35000

50

12/31/07 5:00 AM




I have create a simple tabular rolling forecast report (with cumulative totals) from today (October) thru the next 12 months that looks like this. It smartly works no matter when the report is generated, by starting with this CurrentMonth and moving forward by using 1,2,3,4,etc. in the dateadd: =MonthName(datepart("m",dateadd("m",1,Now())))

The report sample (formatting lost in dropping it in here):




Code Block
















Close Pct
October
November
December
January
February

25.%
$0
$0
$26,625
$0
$0

50.%
$237,500
$110,000
$262,500
$0
$0

75.%
$56,250
$0
$891,075
$0
$0

90.%
$1,051,830
$0
$0
$0
$0

Monthly Total
$1,345,580
$110,000
$1,180,200
$0
$0

Cumulative Total
$1,345,580
$1,455,580
$2,635,780
$2,635,780
$2,635,780





It is working fine....there doesn't seem to be anything wrong with it (all numbers total correctly, etc.), but it is very unelegant.....and I know there must be a better way.

In the righthand most month (which would be September 2008) column, I have a formula that produces the amount (the Monthly Total amount is the same):




Code Block=sum(iif(datepart("m",dateadd("m",11,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0)))




and for the Cumulative Total Amount it gets really hideous, as it is trying to add up all of the totals across the board:




Code Block
=sum(iif(datepart("m",dateadd("m",0,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",1,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",2,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",3,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",4,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",5,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",6,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",7,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",8,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",9,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",10,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0))+iif(datepart("m",dateadd("m",11,Now()))=datepart("m",Fields!EstimatedCloseDate.Value),Cdec(Fields!estimatedvalue.Value*Fields!ClosePct.Value*.01),cdec(0)))




I have searched high and low for examples of reports that do something similar.

Can anyone offer any advice?

Thanks.

View 2 Replies View Related

Pb With Calculated Measure And Totals (grand Total Or Anysubtotals)

May 20, 2008



Hi,

I've created a calculated measure which is a division between 2 other measures which i also have displayed in the cube.
of course as soon as there is some level of aggregation, the shown result is an averaged division and therefore is wrong.


here is some example:
A 16874
B 956
C 1354
D 264
E 103
F 81
G 6
H 3
X 23
Total 5198.36...

here the wanted result would be a simple some of all the other values (=19664)

How could i treat totals/aggregation differently or have any good way of solving this issue?
I know there is the aggregatefunction propertie for normal dimension, but i'm not familiar with calculated measures and it seems properties that can be accessed through BIStudio's interface is rather limited.


thanks a lot in advance for your help. I've been looking for tweaks on the data to trick the cube, but couldn't find any way of getting the result i'm looking for.

View 1 Replies View Related

How To Create A Measure With Count Function

Jan 22, 2005

Hi,
i created a cube that has 2 measures. I created the measures by selecting the columns from my fact table, but the function that applied in the measures was the sum function. I need to apply the count function in my measure. How can i do that?

Thanks in advance.

View 2 Replies View Related

Totals (or Sum) In A Function Or View

Jul 20, 2006

I have the following data in a table:

Item Qty

1 1

1 -1

2 3

2 -1

2 -1



Using a function, how can I code it so that I get the following:

Item Qty

1 0

2 1



Also, if a Qty does equal 0 (as in item 1), can I use a >0 in the Criteria field of the resultant expression to remove it from the Function results?

View 4 Replies View Related

Analysis :: Calculated Measure To Check Measure Value Updates By Month?

May 13, 2015

In my cube there are two measures which are used in different calculations.Now I'm need to show in report if there any months in data when both or even another one of the measures is not updated (value = 0 or NULL).

how should I create the calculated measure for that?

I have tried in mgmt studio to plan this but I'm in a loop of errors.

View 4 Replies View Related

How To Change The Column Measure Into Row Measure In Reporting Services

Sep 25, 2007



Hi,

I am wondering how to create a matrix that contains 1 dimension for Top Label (Column), let's say "Year-Month"
and then 2 Measure to be in the row format rather than columnar format.
Example as below :
Year-Month on the column, and the measure is on the row :









2007-04
2007-05
2007-06

Amount Sales
1000
2000
3000

Unit Sales
10
20
30

Total
1010
2020
3030



Please share with me if you have this solution in Reporting services as it works in excel, hyperion brio, bo, cognos but somehow cannot see that function in Reporting Services.

Thanks
best regards,
Tanipar

View 1 Replies View Related

Reporting Services :: Calculating Grand Totals From Group Totals

May 9, 2015

I have some data grouped in a table by a certain criteria, and for each group it is computed a subtotal for the group. Of the values from each of the group, I want to create a grand total on the report by adding every subtotal from each group.

Example:
...
....
Group1              Value
                           10
                            20
Sub Total 1:         30

Group2                 Value
                              15
                              25
Sub Total 2:           40

Now, I would like to be able to add subtotal 1 (30) to subtotal 2 (40) and my grand total would be 70. Can I accomplish this task in SSRS?

View 5 Replies View Related

SQL 2012 :: Add Calculated Measure As Child Measure

Sep 15, 2015

In SSAS, I want to add a calculated measure and set that measure as the Parent of existing measure. For example I have the measures as A and B from the fact table. Now i want to add a calculated measure as C and set this measure as Parent for measures A and B. How to do that in SSAS.

View 4 Replies View Related

Analysis :: MDX Filter A Measure Based On Another Measure

May 3, 2015

I want to filter a measure based on another measure (both are measures on the same FACT table).Distinct Number of Users HAVING.User Cost above 0.

I tried doing having but because it’s two measures and not a tuple with a dimension it writes an eror.My query is something like:

SELECT
  [Measures].[Distinct Number of Users ]
having [Measures].[User Cost] >0
 ON
COLUMNS,

[code]....
 
Please note, that I want it in a MDX query not needing to change the cube or DWH table.

View 4 Replies View Related

MSOLAP To Do SUM(measure A) /SUM (measure B) In Different Levels

May 17, 2001

So far we are happy with MS OLAP 2000 service.

In the past we did cubes with aggregation method using summary.

MS OLAP server allows aggregate functions (Sum, Min, Max, Count, and Distinct Count).

But now the customer wants to know percentage of SUM(measure A) /SUM (measure B) in different levels and dimension combination.

Any idea?

View 1 Replies View Related

Cumulative Log

Sep 7, 2007

Is it possible to create a cumulative log using SSIS? basiclly I have 5 logs which hold failed records. I would like to create a cumulative log and send it via email using SSIS.
thoughts?

thanks

View 6 Replies View Related

Cumulative Sum(Urgent)

Apr 26, 2000

I'm trying to get the final result using an aggregate function.

Table looks like below;
ID ACRE Probability
1 3 0.3
2 1 0.6
3 6 0.2
4 5 0.5
5 2 0.1

First, I want to descend by probability then select all records that cumulative acre <= 8

So, final result will be:

ID ACRE Probability
2 1 0.6
4 5 0.5

Any idea how to write a script?

Thanks in advance,

Mike Jun
hyunhyo@hotmail.com
GIS reserch Group
University of Colorado
303-492-8781

View 1 Replies View Related

Cumulative Count

Oct 4, 2005

I have to group the no. of employees based on month. i.e

Jan 10 employees
Feb 20 employees
Mar 30 employess

The result is to be

Jan 10
Feb 20
Mar 60.

Kindly provide the sql for getting the above result.

Thanks,
Lakshmi

View 6 Replies View Related

Cumulative Weeks

Jul 20, 2005

SQL Server 2000 SP3Hi,How can I get the cumulative weeks from a givedate to the currentdate. I know I can get the weeknumber by using datepart(wk,getdate())but this will giveme the week number for this year. What if I want to know the number ofweeksthat have passed since june 1 2001. If I use datepart(wk,'20010106') Iwillget the week number for 2001 but I would like the number of weeksexpired between then now.Thanks,Reg

View 1 Replies View Related

Hierarchical Cumulative Sum

Aug 23, 2006

I have a table consisting of 3 columns: Parent varchar(50), Child varchar(50), Pop int.

The table is setup as follows:

Parent Child Pop
----------------------------------
Europe France 0
France Paris 1
New York New York City 10
North America United States 0
North America Canada 0
United States New York 0
United States Washington 0
Washington Redmond 200
Washington Seattle 100
World Europe 0
World North America 0

This is just some sample data modified a tiny bit from an example of a hierachical print out sample that is a stored procedure that allows me to pass any place and see all of that place's children/grandchildren.

I need to figure out how to write a query to show me cumulative sums (ROLLUP?) of the whole tree. So the output should basically be something like this (it can include parent and child columns too):

World Null 311
World Europe 1
Europe France 1
France Paris 1
World North America 310
North America United States 310
North America Canada 0
United States New York 10
United States Washington 300
New York New York City 10
Washington Redmond 200
Washington Seattle 100

Hopefully you understand what i'm looking for. I've tried using WITH ROLLUP and I also tried using an Inner Join but I'm not really sure what I need to do to pull this off. I seem to only be able to get it to work 1-2 levels deep but not through the whole tree.

Any help/ideas would be appreciated! Thank you.

View 13 Replies View Related

Finding Cumulative Sum

Dec 29, 2007

In the emp table :
>
> EMPNO ENAME SAL
> ==================
> 7369 SMITH 1000
> 7499 ALLEN 2000
> 7521 WARD 3000
> 7566 JONES 4000
> 7654 MARTIN 5000
>
> there is a requirement to have a calculated col.
> called cummulative sal
>
> EMPNO ENAME SAL CUMMULATIVE_SAL
> 7369 SMITH 1000 1000
> 7499 ALLEN 2000 3000
> 7521 WARD 3000 6000
> 7566 JONES 4000 10000
> 7654 MARTIN 5000 15000
>
>

How to show this calculated col. by using one select statement?
I could get the result using Empno. in my query as --
select ename,sal,(select sum(sal) from emp k where k.empno <= e.empno) as cum from emp e order by ename

but I was asked to get the same result if empno. col is not there?

SUCKS........... the below code is giving the result but I don't know how you could use operator (<) on two strings to compare......????
select ename,sal,(select sum(sal) from emp k where k.ename <= e.ename) as cum from emp e order by ename

Someone tell me if this is the right approach or is there a better way of getting the thing done.

View 4 Replies View Related

Saving Cumulative Data Or Something Like That :)

May 4, 2007

Hi,There are 3 tablesTable,TableDetails,TableDaily.With structureTABLE:TableID        UserID        Money----------        ----------        ----------(int)            (int)            (money)TABLEDETAILS:TableDetailsID    TableID        ItemID        PaidForItem    DayID----------               ----------        ----------        ----------           ----------(int)                   (int)             (int)            (money)         (int)TABLEDAILY:TableDailyID    TableID        PaidForItem    Money        Total                                 Change----------            ----------        ----------            ----------        ----------                              ----------(int)                (int)             (money)          (money)      (PaidForItem + Money)       (money)"Table"    holds id for user and his money amount, which changes during time. "TableDetails" holds data about items user bought, amount paid for them and dayid which relates to one particular day."TableDaily" holds history. I do not know how to update this table.I created job whish runs stored procedure. This procedure sums "PaidForItem" using group by TableID and WHERE DAYID = '11'.Problem is with Change column. This column sould hold difference between today's Total and previous one etc.Current procedure looks like this:INSERT INTO    TableDaily        (TableID, PaidForItem, Money, DayID)SELECT        TableDetails.TableID,                     SUM(PaidForItem) AS PaidForItem,                     Table.Money,                    (SELECT    DayID                    FROM    Days                    WHERE  (Aktive = 1)) AS DayIDFROM          TableDetails INNER JOIN                    Table ON TableDetails.TableID = Table.TableID GROUP BY    TableDetails.TableID, Table.Money

View 3 Replies View Related

Cumulative Counts With GROUP BY?

Jun 6, 2014

I have the following:

SELECT '201305' AS PAYPERIOD,
EMPLOYEE,
RIGHT ('000' + CAST (DEPT_ID AS VARCHAR(3)) ,3) AS DEPARTMENT,
COUNT (EMPCODE) AS BONUSCOUNT_YTD
FROM Table1
WHERE (YEAR = 2013 AND PERIOD < 2)
GROUP BY EMPCODE, YEAR, PERIOD, DEPT_ID

[Code] ...

How can I get the counts to be cumulative? In other words, if an employee appears in pay period 201305 that's 1, if they then appear in pay period 201306 that becomes 2.

View 4 Replies View Related

Cumulative Result Calculation

Jul 5, 2014

Is there any way to calculate Cumulative result.

Manpower|Count|Cum_Count|Formula
Apr|70|70|Sum(APR)
May|40|110|Sum(Apr+May)
Jun|110|220|Sum(Apr+May+Jun)

View 2 Replies View Related

How To Calculate Cumulative Of Months

Aug 2, 2014

How to calculate the cumulative of months.

Jan FebMar AprMay JunJul AugSep Oct Nov Dec
321 394571 577 617 692924 944956 1010 1308 1686

if i execute my query in this month(getdate) then it should sum from Jan to Aug Similarly i execute same query it should sum from Jan to Sept So on.

View 1 Replies View Related

Cumulative Update Package 2 For SP2

Jun 30, 2007

I tried to install "Cumulative update package 2 for SQL Server 2005 Service Pack 2"
Everything went well except for the "SQL Server Database Services" update.
It errored out as it was trying to "Finalize" the update.

Kicker to this whole thing is the database file "temp_MS_AgentSigningCertificate_database.mdf" does not even exist.

I could not see any references to it in the master database.
I checked the registry and I can find a couple of search references for it.
It apparently may have been a database that existed in the server at one time.

I am not sure if I should remove the registry references to the database.



Below is a part of the install summary where it has failed:
===========================================================
Product Installation Status
Product : SQL Server Database Services 2005 (MSSQLSERVER)
Product Version (Previous): 3050
Product Version (Final) :
Status : Failure
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGHotfixSQL9_Hotfix_KB936305_sqlrun_sql.msp.log
Error Number : 29537
Error Description : MSP Error: 29537 SQL Server Setup has encountered the following problem: [Microsoft][SQL Native Client][SQL Server]A file activation error occurred. The physical file name 'F:Data emp_MS_AgentSigningCertificate_database.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.. To continue, correct the problem, and then run SQL Server Setup again.

If someone can tell me what I need to do to resolve this issue, I would greatly
appreciate it.

Thanks,
Larry :-(

Larry :-)

View 4 Replies View Related

Page Subtotals (Not Cumulative)

Jul 30, 2007

Hello,

I want to display subtotals for a column only for that page. Like;

Index Value
-----------------------------
1 4
2 5
Subtotal 9
----------------------------
3 1
4 2
Subtotal 3
Total 12


RunningValue gives cumulative totals. I need subtotals for each visible page only. Is there a way to do it ?
Constraints:
I'm using a table. And I shouldn't use page breaks on my report.

Thanks in advance

View 3 Replies View Related

Transact SQL :: Cumulative Sum On Value Column

Apr 28, 2015

How would I iterate through this table and do a cumulative sum on the value column :

I'm trying to get the following result:

View 5 Replies View Related

Which Cumulative Update Package For Sp2

Jun 20, 2007

Hi

I have found two cumulative update packages available for sql 2005 sp2 - build 3161 (http://support.microsoft.com/kb/935356) and build 3175 (http://support.microsoft.com/kb/936305).



The fixes are supposed to be cumulative and include all fixes since the last service pack, but the list of hotfixes in each package is different.



Does build 3175 contain the fixes in build 3161? What about fixes mentioned in build 3175 that have version lowere than 3161 - are they included in build 3161?



Anthony

View 1 Replies View Related

How Can I Get The Cumulative Sum Of A Field In A Table

Aug 29, 2007

For Eg.

I have a table like gias given below:
Name Amount
------------------------------
aaa 10
bbb 20

and I want an output like one given below on running SQL query or stored procedure
Name Amount cumulative amount
---------------------------------------------------------------------
aaa 10 10
bbb 20 30

can anyone plz help me on this

View 28 Replies View Related

Transact SQL :: How To Get Cumulative Value In Query

Aug 18, 2015

I have table like below, its period wise ,here the value get cumulative period wise.

amtname period
10CHR201202
20TNG201202
10CHR201203
20TNG201203

View 3 Replies View Related

Query For Cumulative GPA Calculation

Oct 9, 2015

I have a table with the following creation sql script

CREATETABLE [dbo].[TEST_ENROLLMENT](
      [ENROLLMENT_ID] [int]
NOTNULL,
      [COURSE_OFFERING_ID] [int]
NOTNULL,
      [STUDENT_ID] [int]

[Code] ....

Below is the sql insert for the above table’s data

INSERTINTO TEST_ENROLLMENT(ENROLLMENT_ID,COURSE_OFFERING_ID,STUDENT_ID,DEPT_ID,COURSE_CODE,CREDIT,SECTION_ID,
SEMESTER,ACAD_LEVEL,ACAD_YEAR,DATE_ENROLLED,[STATUS],TOTAL_MARK,GRADE_LETTER,QPE,Honor,INSTRUCTOR_ID,USERNAME
)VALUES(877,356,104,15,'IRD

[Code] ...

I was trying to calculate GPA and Commulative GPA (CGPA) for this student and the formula of GPA is SUM(Honor)/SUM(CREDIT) and the formula of the CGPA is the Average of the SUM(Honor)/SUM(CREDIT) grouped by semester and I wrote the below query which is calculating the GPA correctly but wrongly calculating the CGPA.

How to get the correct CGPA shown in the below desired result set table.

select x.STUDENT_ID,AVG(x.gpa)as
GPA,AVG(y.gpa)AS'COMMULATIVE GPA'
from
(
select STUDENT_ID,SUM(Honor)/SUM(CREDIT)
gpa,ACAD_YEAR,SEMESTER

[Code] ....

Current result set (Incorrect CUMULATIVE GPA)

STUDENT_ID GPA CUMULATIVE GPA
104 2.9 2.9
104 2.25 2.25
104 3 3
 
Desired result set

STUDENT_ID GPA COMMUTATIVE GPA
104 2.9 2.9
104 2.25 2.575
104 3 2.716

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved