hi All ,
I have a table that has customer,product,month ,year and month ,information .Sql Scripts
Create Table SampleRevenue
(Customer varchar(30),
Product varchar(30),
SMonth int ,
SYear int,
Total Decimal )
go
Insert into SampleRevenue
Values('Sam','Switch',1,2014,300.50)
Insert into SampleRevenue
Values('Sam','Clutch',1,2014,100)
Insert into SampleRevenue
Values('Sam','Viper',1,2014,50)
Insert into SampleRevenue
Values('Tom','Viper',1,2014,50)
Insert into SampleRevenue
Values('Tom','Viper',2,2014,50)
Insert into SampleRevenue
Values('Tom','Belt',2,2014,50)
Insert into SampleRevenue
Values('Tom','Dash',3,2014,50)
Insert into SampleRevenue
Values('Ron','Dash',3,2014,100)
Insert into SampleRevenue
Values('Ron','Dash',4,2014,150)
Insert into SampleRevenue
Values('Ron','Dash',4,2014,150)
Insert into SampleRevenue
Values('Tom','Dash',4,2014,150)
Insert into SampleRevenue
Values('Tom','Belt',5,2014,150)
Insert into SampleRevenue
Values('Ron','Viper',5,2014,150)
Insert into SampleRevenue
Values('Ron','Belt',5,2014,150)
Insert into SampleRevenue
Values('Tom','Belt',5,2014,150)
Insert into SampleRevenue
Values('Tom','Belt',5,2014,150)
Insert into SampleRevenue
Values('Tom','Belt',6,2014,150)
go
So like if i want to check the result for the current quarter . The output should be like below :
Note ( '.' in the table is just used for the formatting as without it the column layout was out of order)
Please help
Thanks in Advance
Priya
Customer | Product | Month | Total |
Ron | Dash | Apr-14 | 150 |
Ron | Dash | Apr-14 | 150 |
Ron | Viper | May-14 | 150 |
Ron | Belt | May-14 | 150 |
Ron | . | April14 -May14 | 0 |
Tom | Dash | Apr-14 | 150 |
Tom | Belt | May-14 | 450 |
Tom | . | April14-May14 | -350 |
Tom | Belt | Jun-14 | 150 |
Tom | . | May14 - June14 | 300 |