13-07-20, 03:54 PM
السلام عليكم اخواني
ارجو المساعدة في تعديل نص الاسكوال الخاص بي
النص يقوم في حالة ما اذا كان التاريخ موجود او تاريخ صحيح : بحساب المدة بين تاريخين بالشهر والايام ويقوم بضربها في مبلغ التعويض في عدد الاشخاص المستفيدين منها
مثال: عدد الاشخاص 2، مبلغ التعويض 4000دج، الفترة ما بين 2020/01/04 الى 2020/02/18 (1 شهر و 14 يوما)
(((4000دج *14 يوما)/30 ) + (4000دج*1شهر)) * 2 عدد الاشخاص =11733.33دج
الاشكال في query
اذا كان الملف به تعويض واحد يقوم بالحساب، واذا كان الملف به مجموعة من التعويضات يظهر خطا
Msg 512, Level 16, State 1, Line 4
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Msg 512, Level 16, State 1, Line 14
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
السؤال:
كيف يمكنني اظهار جميع التعويضات والحسابات الموافقة لها لكل ملف على حدى بحيث اذا قمت بتغيير رقم الملف مثلا "20/0003"
ارجو المساعدة في تعديل نص الاسكوال الخاص بي
النص يقوم في حالة ما اذا كان التاريخ موجود او تاريخ صحيح : بحساب المدة بين تاريخين بالشهر والايام ويقوم بضربها في مبلغ التعويض في عدد الاشخاص المستفيدين منها
مثال: عدد الاشخاص 2، مبلغ التعويض 4000دج، الفترة ما بين 2020/01/04 الى 2020/02/18 (1 شهر و 14 يوما)
(((4000دج *14 يوما)/30 ) + (4000دج*1شهر)) * 2 عدد الاشخاص =11733.33دج
الاشكال في query
اذا كان الملف به تعويض واحد يقوم بالحساب، واذا كان الملف به مجموعة من التعويضات يظهر خطا
Msg 512, Level 16, State 1, Line 4
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Msg 512, Level 16, State 1, Line 14
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
السؤال:
كيف يمكنني اظهار جميع التعويضات والحسابات الموافقة لها لكل ملف على حدى بحيث اذا قمت بتغيير رقم الملف مثلا "20/0003"
كود :
declare @days int
declare @month int
declare @Total dec(18,2)
if (select isdate(date_debut1) from Indemnite where id_aff='20/0002') =1 begin
select @month = DateDiff(month, date_debut1, date_fin1) from indemnite
select @days = DateDiff(day, DateAdd(month, DateDiff(month, date_debut1, date_fin1), date_debut1), date_fin1) from indemnite where id_aff='20/0002'
if @days < 0 begin
select @month=@month-1 from indemnite
select @days = DateDiff(day, DateAdd(month, @month, date_debut1), date_fin1) from indemnite where id_aff='20/0002'
end
select @month=@month *1% 12
select @Total =(((montant_dette1 * @days)/30)+(montant_dette1 *@month))* n_personne1 from Indemnite where id_aff='20/0002'
end
if (select isdate(date_debut1)from Indemnite where id_aff='20/0002') =0 begin
select @Total =(montant_dette1 * n_personne1) from Indemnite where id_aff='20/0002'
end
select Indemnite1, n_personne1, date_debut1, date_fin1, montant_dette1,@Total as Total FROM Indemnite where id_aff='20/0002'