, Guest>> || || |
/ Microsoft SQL Server
    [new]
Cami
Member

:
: 15
!
. ,

7012 202 03 269 16 001 300
7035 202 35 269 16 001 400
8633 202 58 269 16 001 500
1456 207 03 269 16 001 600
2365 208 03 269 16 001 700
7895 269 16 269 16 001 800


NR= ∑(=269 and =16) -
ZP202= ∑(=202 and in(03,35)) -
ZP207= ∑(=207 and in(03,35 and)) -
KR=NR/ (ZP202+ ZP207)
:
( )
=111, =254, =632, =NR*ZP207
( . , ( ), )
( UNION ALL)
=222, =365, =709, =NR*ZP208
( , . , )
, UNION ALL
=333, =864, =356, =KR-ZP208-ZP207
( - . , , )
, ܔ (-=.)???

2 11, 11:09[11369491]      |
 Re:   [new]

Guest
Cami
...
, ܔ (-=.)???

, ,
2 11, 11:21[11369504]      |
 Re:   [new]
Cami
Member

:
: 15
[/quot]
, , [/quot]
, ? (
2 11, 11:56[11369535]      |
 Re:   [new]

Guest
Cami,

-
select , , , 
case 
	when =111 and =254 and =632 then a.NR*a.ZP207
	when =222 and =365 and =709 then a.NR*a.ZP208
	when =333 and =864 and =356 then a.KR-a.ZP208-a.ZP207
end as 

from 

cross join

(select 
sum(case when =269 and =16 then  else 0 end) as NR,
sum(case when =202 and  in (03,35) then  else 0 end) as ZP202,
sum(case when =207 and  in (03,35) then  else 0 end) as ZP207,
sum(case when =269 and =16 then  else 0 end)/
	(sum(case when =202 and  in (03,35) then  else 0 end)+ 
	 sum(case when =207 and  in (03,35) then  else 0 end)) as KR
from  ) a

where (=111 and =254 and =632)
   or (=222 and =365 and =709)
   or (=333 and =864 and =356)
2 11, 12:18[11369559]      |
 Re:   [new]
Cami
Member

:
: 15
Cami,

-
select , , , 
case 
	when =111 and =254 and =632 then a.NR*a.ZP207
	when =222 and =365 and =709 then a.NR*a.ZP208
	when =333 and =864 and =356 then a.KR-a.ZP208-a.ZP207
end as 

from 

cross join

(select 
sum(case when =269 and =16 then  else 0 end) as NR,
sum(case when =202 and  in (03,35) then  else 0 end) as ZP202,
sum(case when =207 and  in (03,35) then  else 0 end) as ZP207,
sum(case when =269 and =16 then  else 0 end)/
	(sum(case when =202 and  in (03,35) then  else 0 end)+ 
	 sum(case when =207 and  in (03,35) then  else 0 end)) as KR
from  ) a

where (=111 and =254 and =632)
   or (=222 and =365 and =709)
   or (=333 and =864 and =356)


!!!!!
2 11, 12:20[11369561]      |
 Re:   [new]
Cami
Member

:
: 15
.
. , .
. ,

7012 202 03 269 16 001 300
7035 202 35 269 16 001 400
8633 202 58 269 16 001 500
1456 207 03 269 16 001 600
2365 208 03 269 16 001 700
7895 269 16 269 16 001 800


NR= ∑(=269 and =16) -
ZP202= ∑(=202 and in(03,35)) -
ZP207= ∑(=207 and in(03,35 and)) -
KR=NR/ (ZP202+ ZP207)

-
:
='aaa', ='bbb', ='ccc', ='ddd' , =KR*ZP207
='iii', ='fff', ='jjj', ='kkk', =KR*ZP208
='mmm', ='nnn', ='xxx', ='yyy', =KR-ZP207-ZP208

.. ' ' ( ) - , ,

- )
4 11, 16:08[11382466]      |
 Re:   [new]
Cami
Member

:
: 15
, !
8 11, 06:53[11406587]      |
 Re:   [new]

Guest
select b.*,
case 
	when id=1 then a.NR*a.ZP207
	when id=2 then a.NR*a.ZP208
	when id=3 then a.KR-a.ZP208-a.ZP207
end as 

from

(select 1 as id, 'aaa' as , 'bbb' as , 'ccc' as , 'ddd' as  union all
select 2, 'iii', 'fff', 'jjj', 'kkk' union all
select 3, 'mmm', 'nnn', 'xxx', 'yyy') b

cross join

(select 
sum(case when =269 and =16 then  else 0 end) as NR,
sum(case when =202 and  in (03,35) then  else 0 end) as ZP202,
sum(case when =207 and  in (03,35) then  else 0 end) as ZP207,
sum(case when =269 and =16 then  else 0 end)/
	(sum(case when =202 and  in (03,35) then  else 0 end)+ 
	 sum(case when =207 and  in (03,35) then  else 0 end)) as KR
from  ) a
8 11, 07:43[11406593]      |
 Re:   [new]
Cami
Member

:
: 15
)
, )
8 11, 08:11[11406599]      |
/ Microsoft SQL Server