Quarters

Jun 25, 2007

Hi agian. Another probs. I need help again....

DECLARE @quarter varchar(10), @year int
SET @quarter = 'First' --First, Second, Third, Fourth
SET @year = 2007

table1 - hrEmpPaySumm

empno period1 sss_ee sss_er
1 1/1/2007 500 100
1 3/1/2007 600 200
1 3/16/2007 700 300
2 4/1/2007 800 400
3 4/1/2007 900 500

expected result...
if @quarter = 'First' AND @year = 2007 - returns all data of jan,feb,mar of 2007
empno month1 sss_ee1 sss_er1 month2 sss_ee2 sss_er2 month3 sss_ee3 sss_er3
1 January 500 100 Feb 0 0 March 1100 500
2 January 0 0 Feb 0 0 March 0 0
3 January 0 0 Feb 0 0 March 0 0


if @quarter = 'Second' AND @year = 2007 - returns all data of apr,may,jun of 2007
empno month1 sss_ee1 sss_er1 month2 sss_ee2 sss_er2 month3 sss_ee3 sss_er3
1 April 0 0 May 0 0 June 0 0
2 April 800 400 May 0 0 June 0 0
3 April 900 500 May 0 0 June 0 0

and so on....

-Thanks







-Ron-

"A logician trying to explain logic to a programmer is like a cat trying to explain to a fish what it's like to get wet."

View 4 Replies


ADVERTISEMENT

Past Two And Next Two Quarters

Nov 20, 2015

I want past two and next two quarters from the present quarterLike now its 4th quarter i should get 3rd and 2nd quarter and next two quarters that is 1st and 2nd also this is my table and when the year changes data is not fetched correctly

View 10 Replies View Related

Grouping Months Into Quarters

Aug 14, 2012

I have the following query, which is producing the results, which i need.

SELECT
*
FROM
(
SELECT
o.FDMSAccountNo,
DATEADD(DAY,DATEDIFF(DAY,0,hst_date_processed),0) AS FirstDayOfMonth,
SUM(hst_sales_amt) AS 'Total'

[Code] ....

However I want to create an additional four columns, which gives me the quarterly sales amount

E.g.
FDMSAccount no 20120101 20120201 20120301
878743915885 NULL10000 35000

So the quarter sales amount for fdmsaccount no 878743915885 is 45000...

View 1 Replies View Related

How To Calculate The Least Anmongst A List Of Quarters

Oct 25, 2006

Hi,



i get a list of Quarters that look like following as an input to my proc.

'Q306/Q106/Q406/Q405'



I need to find out whihc one of the above is the least Quarter value.

In the above example it is 'Q405'

The Quarter values that come into the proc keep changing...It could be even 1 or 2 or 3 Quarters etc...

Is there any datatype called Quarter in SQL Server.It shows Quarter as a key word...

Can some one please help on this....

View 9 Replies View Related

Analysis :: Annualized Amount Based On Completed Quarters

Aug 26, 2015

I would like to add a calculation to provide an annualized Gross Amount value.  Most solutions I have seen are for annualizing down to the day.  For instance, if today is the 123rd day of the year, the calculation would be Amount / 123 * 365.  What I want to do is annualize the amount based only on completed periods.  Today is 8/26.  

The last completed quarter ended on 6/30.  Therefore I want to basically take the sum of Q1 and Q2, divide by two, and multiply by four to get an annualized amount based on completed quarters.  Eventually I want to do something similar with months.

So here's what I have so far.  In my DSV my DimDate is actually based on a view.  The view has a Date column with the actual date, all of the normal fields you would expect in a DimDate table, and two columns that look like this:

CASE
WHEN [Date] < DATEADD(QQ, DATEDIFF(QQ, 0, GETDATE()), 0)
THEN 'Y'
ELSE 'N'
END AS
CompletedQuarter,

[Code] ....

Note that for dates between 1/1 and 3/31 the CompletedQuarterCount will be 0.  I want any annualized amount to be 0 in that case because I only want to use completed quarters in my calculation.

I added both to my Pay Date dimension (which uses vwDimDate from the DSV) in the cube.  I have tried the calculation below and in my Excel pivot table I'm getting blanks for the calculated field.

CREATE MEMBER CURRENTCUBE.[Measures].[Gross Amount Annualized by Pay Date Quarter]
AS SUM(
IIF([Pay Date].[Pay Date Completed Quarter Count] > 0,
[Gross Amount] / [Pay Date].[Pay Date Completed Quarter Count] * 4,
0)
),
FORMAT_STRING = "Currency",
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Fact Claim' ;

So, is my calculation correct?

View 2 Replies View Related







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