Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to split date for each quarter 1

Status
Not open for further replies.

see123

Programmer
May 11, 2001
28
0
0
US
Here is my Initial data

Name Date Bonus
ABC 1/1/2004 200
ABC 1/4/2004 200
ABC 1/7/2004 200
ABC 1/10/2004 200
ABC 1/2/2004 200
ABC 1/5/2004 200
ABC 1/8/2004 200
ABC 1/11/2004 200

I want to make this data to display like this

Name QTR1_2004 QTR2_2004 QTR3_2004 QTR4_2004
abc 400 400 400 400

Any Ideas please.......
 
Not exactly what you were looking for, but....

Code:
Set DateFormat DMY
Declare @Temp Table(Name VarChar(10), Date DateTime, Bonus Int)

Insert Into @Temp Values('ABC','1/1/2004 ',  200)
Insert Into @Temp Values('ABC','1/4/2004 ',  200)
Insert Into @Temp Values('ABC','1/7/2004 ',  200)
Insert Into @Temp Values('ABC','1/10/2004',  200)
Insert Into @Temp Values('ABC','1/2/2004 ',  200)
Insert Into @Temp Values('ABC','1/5/2004 ',  200)
Insert Into @Temp Values('ABC','1/8/2004 ',  200)
Insert Into @Temp Values('ABC','1/11/2004',  200)

Select Name, 
       DateAdd(Quarter, DateDiff(Quarter, 0, Date), 0) As Quarter,
       Sum(Bonus)
From   @Temp
Group By Name, DateAdd(Quarter, DateDiff(Quarter, 0, Date), 0)


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top