-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaporanHarianPelaksanaan.sql
52 lines (41 loc) · 1.06 KB
/
LaporanHarianPelaksanaan.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
create procedure LaporanHarianPelaksanaan
@tanggal date,
@idPenyelenggara int
as
create table #temp(
IdKegiatan int
)
create table #result(
sudahDivaksin int,
ditolak int
)
insert into #temp
select IdKegiatan
from KegiatanVaksinasi
where IdPenyelenggara = @idPenyelenggara and tanggal = @tanggal
declare curs CURSOR FOR
select *
from #temp
open curs
declare @currKegiatan int
fetch next from curs into @currKegiatan
while @@FETCH_STATUS = 0
begin
declare @tahapanKegiatan varchar(6)
select @tahapanKegiatan = urutanTahapan from Penyelenggara where IdPenyelenggara = @idPenyelenggara
declare @urutanTerakhir int = cast(right(@tahapanKegiatan,1) as int)
insert into #result values
((select count(IdM)
from Mengikuti
where IdKegiatan = @currKegiatan and IdTahapan = @urutanTerakhir)
,
(select count(IdM)
from Pendaftaran
where IdKegiatan = @currKegiatan and statusP = 'Ditolak'))
fetch next from curs into @currKegiatan
end
close curs
deallocate curs
select *
from #result
exec LaporanHarianPelaksanaan '2021-12-18',2