SQLTeam.com | Weblogs | Forums

A matter of creating a group


#1

Hello to everyone,
I hope you are well. I'm having a problem somewhere and I can not solve it :frowning:

create table table1 (HSPKOD varchar(30), Fisno int, aciklama varchar(30), Borc varchar(30), Alacak varchar(30))
INSERT INTO table1 (HSPKOD, Fisno, aciklama, Borc, Alacak)
values
(600.10,1,'A Ltd.',Null,6500),
(391.10,1,'A Ltd.',Null,1000),
(100.10,1,'A Ltd.',7500,Null),
(600.10,1,'A Ltd.',Null,6500),
(391.10,1,'A Ltd.',Null,1000),
(120.10,1,'A Ltd.',7500,Null),
(600.10,2,'B Ltd.',Null,6700),
(391.10,2,'B Ltd.',Null,1200),
(100.10,2,'C Ltd.',7900,Null);

I give the conditions:
1- Hspkod '100%' and Borc >7000
2- Hspkod '100%' with Hspkod '600%' => "Fisno" and "aciklama" be synchronized ( 100% and 600% => "1" and "A Ltd." )

As a result, only those who start with '100%' meeting the conditions below will be given

Result:
HSPKOD Fisno aciklama Borc Alacak
(100.10,1,'A Ltd.,7500,Null)

I hope I can tell it right.
Thank you.