Hi!
I used below script, but couldn't got requirement result.
DECLARE @Deprec AS TABLE(Namber INT,Deprecate int,Price INT, Counters Int)
INSERT INTO @Deprec VALUES(1,7,1500,11021)
INSERT INTO @Deprec VALUES(2,15,10000,11031)
INSERT INTO @Deprec VALUES(3,15,20000,11031)
INSERT INTO @Deprec VALUES(4,20,12500,11031)
INSERT INTO @Deprec VALUES(5,7,11000,11041)
INSERT INTO @Deprec VALUES(6,7,20000,11041)
INSERT INTO @Deprec VALUES(7,20,15500,11551)
INSERT INTO @Deprec VALUES(8,20,1500,11051)
INSERT INTO @Deprec VALUES(9,15,13000,11051)
select Namber, Deprecate, SUM(Price)Price, Counters from @Deprec group by Counters, Namber, Price, Deprecate
My requirement result:
Namber
|
Deprecate
|
Price
|
Count
|
1
|
7
|
1500
|
11021
|
2
|
15
|
30000
|
11031
|
3
|
20
|
12500
|
11031
|
4
|
7
|
31000
|
11041
|
5
|
20
|
17000
|
11051
|
6
|
15
|
13000
|
11051
|