Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use master
- go
- if DB_ID('TestData') IS NOT NULL
- drop database TestData
- go
- create database TestData
- go
- use TestData
- go
- Create table Base
- (
- SBase int
- )
- insert into Base (SBase) values
- (18000), (18100),(18200),(18300),(18400),(18500)
- go
- create or alter function BaseCalculation(@SBase float, @valueA float , @ValueB float )
- returns @ResultTable table
- (
- SBase int,
- Sout float,
- Spost float,
- Cotis float,
- Salarie float
- )
- as
- BEGIN
- declare @fValueA float = @valueA /100
- declare @fValueB float = @valueB /100
- declare @Sout float = @SBase * @fValueA
- declare @SPost float = @SBase + @Sout
- declare @Cotis float = @Spost * @FValueb
- declare @Salarie float = @Spost - @Cotis
- insert into @ResultTable
- values (@SBase, @Sout, @SPost, @Cotis, @Salarie)
- return
- END
- go
- select
- b.SBase, Calculations.* from Base B
- cross apply
- dbo.BaseCalculation(b.SBase, 5,9) as Calculations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement