Hi,
I have a table like below
create table #mytable (vouno varchar(20), voudate date, procedure varchar(10), Amount decimal(18,3))
insert into #mytable values ('1001','01/01/2021','A', 100)
insert into #mytable values ('1001','01/01/2021','B', 200)
insert into #mytable values ('1001','01/01/2021','B', 200)
insert into #mytable values ('1001','02/01/2021','B', 200)
insert into #mytable values ('1001','02/01/2021','B', 200)
insert into #mytable values ('1001','03/01/2021','A', 100)
insert into #mytable values ('1001','03/01/2021','A', 100)
insert into #mytable values ('1002','01/01/2021','A', 100)
insert into #mytable values ('1002','01/01/2021','A', 100)
insert into #mytable values ('1002','02/01/2021','B', 200)
insert into #mytable values ('1002','02/01/2021','A', 100)
i need to select the record for the same date and voucher should not have amount for both procedure 'A' and 'B'
in the above data vouno 1001 and date '01/01/2021' have amount for procedure 'A' and 'B' and
vouno 1002 and date '02/01/2021' have amount for procedure 'A' and 'B'
i need that two records only
Thanks
Kasim
What I have tried:
Hi,
I have a table like below
create table #mytable (vouno varchar(20), voudate date, procedure varchar(10), Amount decimal(18,3))
insert into #mytable values ('1001','01/01/2021','A', 100)
insert into #mytable values ('1001','01/01/2021','B', 200)
insert into #mytable values ('1001','01/01/2021','B', 200)
insert into #mytable values ('1001','02/01/2021','B', 200)
insert into #mytable values ('1001','02/01/2021','B', 200)
insert into #mytable values ('1001','03/01/2021','A', 100)
insert into #mytable values ('1001','03/01/2021','A', 100)
insert into #mytable values ('1002','01/01/2021','A', 100)
insert into #mytable values ('1002','01/01/2021','A', 100)
insert into #mytable values ('1002','02/01/2021','B', 200)
insert into #mytable values ('1002','02/01/2021','A', 100)
i need to select the record for the same date and voucher should not have amount for both procedure 'A' and 'B'
in the above data vouno 1001 and date '01/01/2021' have amount for procedure 'A' and 'B' and
vouno 1002 and date '02/01/2021' have amount for procedure 'A' and 'B'
i need that two records only
Thanks
Kasim