المشاركات : 418
المواضيع 147
الإنتساب : May 2018
السمعة :
4
الشكر: 261
تم شكره 272 مرات في 163 مشاركات
السلام عليكم احبتى فى الله
ممكن كود بحث بين تاريخين مع اظهار الرصيد فى الفتره السابقه لفتره البحث
او اظهار باقى رصيد قبل فتره البحث
وشكراااااااا
المشاركات : 418
المواضيع 147
الإنتساب : May 2018
السمعة :
4
الشكر: 261
تم شكره 272 مرات في 163 مشاركات
لو سمحتوا احبتى فى الله
هل من طريقه عمل كشف حساب مثل هذا
للاسف انا عملت نفس الكشف ولكن صعب على احضار الرصيد السابق قبل فترة البحث بين تاريخين فى التقرير
فهل من طريقه اضاف الرصيد السابق او كود ووضعه فى الداتا جريد فيو بين تاريخين
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
هذه مجموعة استعلامات ممكن ان تفيدك :
PHP كود :
use alasem0; -- إستعلام عن حساب برقم 1811 بين تاريخين Select * From daybook Where AccountDate Between '2020-09-01' And '2021-04-15' And AccountID=1811; -- إستعلام عن حساب برقم 1811 بين تاريخين مع جمع الحسابات المدينة و الدائنة Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(BalanceAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-01' And '2021-04-15' And AccountID=1811; -- إستعلام عن حساب برقم 1811 بين قبل تاريخ معين مع جمع الحسابات المدينة و الدائنة و استخراج الرصيد Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate < '2020-09-01' And AccountID=1811; -- إستعلام جمع و استخراج الرصيد عن حساب معين بين تاريخين 1811 هو رقم حساب الصندوق Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-01' And '2021-04-15' And AccountID=1811;
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
و هذا الاستعلام الذي تريده :
PHP كود :
-- إستعلام عن حساب برقم 1811 بين قبل تاريخ معين مع جمع الحسابات المدينة و الدائنة و استخراج الرصيد Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate < '2020-09-01' And AccountID=1811 -- إستعلام جمع و استخراج الرصيد عن حساب معين بين تاريخين 1811 هو رقم حساب الصندوق UNION ALL Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-01' And '2021-04-15' And AccountID=1811;
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 418
المواضيع 147
الإنتساب : May 2018
السمعة :
4
الشكر: 261
تم شكره 272 مرات في 163 مشاركات
(13-10-21, 03:12 PM)asemshahen5 كتب : و هذا الاستعلام الذي تريده :
PHP كود :
-- إستعلام عن حساب برقم 1811 بين قبل تاريخ معين مع جمع الحسابات المدينة و الدائنة و استخراج الرصيد Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate < '2020-09-01' And AccountID=1811 -- إستعلام جمع و استخراج الرصيد عن حساب معين بين تاريخين 1811 هو رقم حساب الصندوق UNION ALL Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-01' And '2021-04-15' And AccountID=1811;
الف شكر على الرد السريع اخى الكريم ولكن لم افهم الطريقه ممكن شرح بمثال توضيحى بسيط
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
13-10-21, 09:50 PM
(آخر تعديل لهذه المشاركة : 13-10-21, 11:05 PM {2} بواسطة asemshahen5.)
هذا سكربت انشاء الجدول :
PHP كود :
/****** Object: Table [dbo].[daybook] Script Date: 10/13/2021 8:43:46 PM ******/ SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
CREATE TABLE [dbo].[daybook]( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountStatement] [nvarchar](50) NULL, [AccountMoneyName] [int] NOT NULL, [AccountDate] [date] NOT NULL, [AccountNum] [int] NOT NULL, [Accounting] [int] NOT NULL, [AutoNumbering] [int] IDENTITY(1,1) NOT NULL, [IsDeleteed] [bit] NULL, CONSTRAINT [PK_daybook] PRIMARY KEY CLUSTERED ( [AutoNumbering] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
GO
و هذه بعض معلومات قيود يومية لتجرب عليها :
PHP كود :
INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,1811,N'الصندوق',N'دفعة من زبون',1,'2020-08-02',1,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,161,N'الزبائن',N'دفعة من زبون',1,'2020-08-02',1,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,1162,N'آلات كاتبة وحاسبة1',N'شراء اثاث',1,'2020-08-03',2,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,1811,N'نقدي بالصندوق',N'شراء اثاث',1,'2020-08-03',2,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (125000,0,125000,112,N'مباني',N'قيود إثبات موجودات الشركة',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,150000,116,N'اثاث ومعدات مكاتب',N'قيود إثبات موجودات الشركة',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,175000,1811,N'الصندوق',N'إثبات الموجودات الصندوق',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,200000,182,N'المصرف',N'إثبات الموجودات المتداولة المصرف',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,200000,0,21,N'رأس المال',N'قيود إثبات رأس المال',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (15000,0,15000,1811,N'نقدي بالصندوق',N'لا يوجد',1,'2020-09-13',4,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,15000,0,16106,N'الزبون 1',N'لا يوجد',1,'2020-09-13',4,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1200,0,1200,1811,N'نقدي بالصندوق',N'لا يوجد',1,'2020-09-13',5,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1200,0,16106,N'الزبون 1',N'لا يوجد',1,'2020-09-13',5,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (10000,0,10000,1811,N'نقدي بالصندوق',N'دفعة على الحساب',1,'2020-11-03',6,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,10000,0,16106,N'الزبون 1',N'دفعة على الحساب',1,'2020-11-03',6,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,339,N'مصروفات خدمية متنوعة',N'رواتب وأجور نقدية ومتمماتها عن العمل الفعلي',1,'2020-11-03',7,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,1811,N'نقدي بالصندوق',N'رواتب وأجور نقدية ومتمماتها عن العمل الفعلي',1,'2020-11-03',7,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (21000,0,21000,343,N'المشتريات',N'لا يوجد .',1,'2021-04-15',8,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,21000,0,1811,N'نقدي بالصندوق',N'لا يوجد .',1,'2021-04-15',8,'1',0);
و جرب عليه هذا الاستعلام :
PHP كود :
use QtnDB1; drop table #temp CREATE TABLE #temp ( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountDate] [date] NOT NULL, ) ON [PRIMARY] delete from #temp insert into #temp (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountDate) (Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,'2020-09-09' From DayBook Where AccountDate < '2020-09-10' And AccountID=1811 group by AccountID,AccountName) select * from #temp UNION ALL Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-10' And '2021-04-15' And AccountID=1811 group by AccountID,AccountName,AccountDate;
جدول دفتر اليومية قبل الاستعلام :
جدول اليومية بعد الاستعلام :
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 418
المواضيع 147
الإنتساب : May 2018
السمعة :
4
الشكر: 261
تم شكره 272 مرات في 163 مشاركات
14-10-21, 04:42 AM
(آخر تعديل لهذه المشاركة : 14-10-21, 11:34 AM {2} بواسطة خالد كامل1.)
(13-10-21, 09:50 PM)asemshahen5 كتب : هذا سكربت انشاء الجدول :
PHP كود :
/****** Object: Table [dbo].[daybook] Script Date: 10/13/2021 8:43:46 PM ******/ SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
CREATE TABLE [dbo].[daybook]( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountStatement] [nvarchar](50) NULL, [AccountMoneyName] [int] NOT NULL, [AccountDate] [date] NOT NULL, [AccountNum] [int] NOT NULL, [Accounting] [int] NOT NULL, [AutoNumbering] [int] IDENTITY(1,1) NOT NULL, [IsDeleteed] [bit] NULL, CONSTRAINT [PK_daybook] PRIMARY KEY CLUSTERED ( [AutoNumbering] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
GO
و هذه بعض معلومات قيود يومية لتجرب عليها :
PHP كود :
INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,1811,N'الصندوق',N'دفعة من زبون',1,'2020-08-02',1,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,161,N'الزبائن',N'دفعة من زبون',1,'2020-08-02',1,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,1162,N'آلات كاتبة وحاسبة1',N'شراء اثاث',1,'2020-08-03',2,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,1811,N'نقدي بالصندوق',N'شراء اثاث',1,'2020-08-03',2,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (125000,0,125000,112,N'مباني',N'قيود إثبات موجودات الشركة',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,150000,116,N'اثاث ومعدات مكاتب',N'قيود إثبات موجودات الشركة',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,175000,1811,N'الصندوق',N'إثبات الموجودات الصندوق',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (25000,0,200000,182,N'المصرف',N'إثبات الموجودات المتداولة المصرف',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,200000,0,21,N'رأس المال',N'قيود إثبات رأس المال',1,'2020-09-02',3,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (15000,0,15000,1811,N'نقدي بالصندوق',N'لا يوجد',1,'2020-09-13',4,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,15000,0,16106,N'الزبون 1',N'لا يوجد',1,'2020-09-13',4,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1200,0,1200,1811,N'نقدي بالصندوق',N'لا يوجد',1,'2020-09-13',5,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1200,0,16106,N'الزبون 1',N'لا يوجد',1,'2020-09-13',5,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (10000,0,10000,1811,N'نقدي بالصندوق',N'دفعة على الحساب',1,'2020-11-03',6,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,10000,0,16106,N'الزبون 1',N'دفعة على الحساب',1,'2020-11-03',6,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (1000,0,1000,339,N'مصروفات خدمية متنوعة',N'رواتب وأجور نقدية ومتمماتها عن العمل الفعلي',1,'2020-11-03',7,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,1000,0,1811,N'نقدي بالصندوق',N'رواتب وأجور نقدية ومتمماتها عن العمل الفعلي',1,'2020-11-03',7,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (21000,0,21000,343,N'المشتريات',N'لا يوجد .',1,'2021-04-15',8,1,0); INSERT INTO daybook (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountMoneyName,AccountDate,AccountNum,Accounting,IsDeleteed) VALUES (0,21000,0,1811,N'نقدي بالصندوق',N'لا يوجد .',1,'2021-04-15',8,'1',0);
و جرب عليه هذا الاستعلام :
PHP كود :
use QtnDB1; drop table #temp CREATE TABLE #temp ( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountDate] [date] NOT NULL, ) ON [PRIMARY] delete from #temp insert into #temp (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountDate) (Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,'2020-09-09' From DayBook Where AccountDate < '2020-09-10' And AccountID=1811 group by AccountID,AccountName) select * from #temp UNION ALL Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountDate From DayBook Where AccountDate Between '2020-09-10' And '2021-04-15' And AccountID=1811 group by AccountID,AccountName,AccountDate;
جدول دفتر اليومية قبل الاستعلام :
جدول اليومية بعد الاستعلام :
اخى الحبيب كل ده بعرف اعمله انا مشكلتى فى البحث بين تاريخين عايز رصيد العميل قبل التاريخ اللى ببحث عليه فاهمنى مكان السهم اللى فى الصوره بتاعت التقرير فى اول مشاركه
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
14-10-21, 02:26 PM
(آخر تعديل لهذه المشاركة : 14-10-21, 02:51 PM {2} بواسطة asemshahen5.)
اخي العزيز كل ما طلبته موجود في الاستعلام و أضفت الاستعلام الشرح لكي تفهمه على فكرة أول سجل في الصورة الثانية هو الرصيد السابق :
PHP كود :
use QtnDB1; -- حذف جدول ان وجد if OBJECT_ID('tempdb..#temp') is not null begin drop table #temp PRINT 'Exist' end -- إنشاء الجدولمختصر عن دفتر اليومية CREATE TABLE #temp ( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountStatement] [nvarchar](50) NOT NULL, [AccountDate] [date] NOT NULL, [AutoNumbering] [int] NOT NULL, ) ON [PRIMARY] -- تفريغ الجدول delete from #temp -- هذا إستعلام إضافة سجل رصيد الزبون قبل البحث بين تاريخين insert into #temp (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering) (Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,N'رصيد سابق','2020-09-09',1 From DayBook Where AccountDate < '2020-09-10' And AccountID=1811 group by AccountID,AccountName) -- جلب سجل الرصيد و معلوماته select * from #temp -- دمج النتيجتين الخاصتين بكشف الحساب UNION ALL -- إستعلام البحث عن حساب بين تاريخين Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering From DayBook Where AccountDate Between '2020-09-10' And '2021-04-15' And AccountID=1811 group by AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering;
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
المشاركات : 418
المواضيع 147
الإنتساب : May 2018
السمعة :
4
الشكر: 261
تم شكره 272 مرات في 163 مشاركات
(14-10-21, 02:26 PM)asemshahen5 كتب : اخي العزيز كل ما طلبته موجود في الاستعلام و أضفت الاستعلام الشرح لكي تفهمه على فكرة أول سجل في الصورة الثانية هو الرصيد السابق :
PHP كود :
use QtnDB1; -- حذف جدول ان وجد if OBJECT_ID('tempdb..#temp') is not null begin drop table #temp PRINT 'Exist' end -- إنشاء الجدولمختصر عن دفتر اليومية CREATE TABLE #temp ( [DebitAccount] [decimal](18, 2) NOT NULL, [CreditAccount] [decimal](18, 2) NOT NULL, [BalanceAccount] [decimal](18, 2) NOT NULL, [AccountID] [int] NOT NULL, [AccountName] [nvarchar](50) NOT NULL, [AccountStatement] [nvarchar](50) NOT NULL, [AccountDate] [date] NOT NULL, [AutoNumbering] [int] NOT NULL, ) ON [PRIMARY] -- تفريغ الجدول delete from #temp -- هذا إستعلام إضافة سجل رصيد الزبون قبل البحث بين تاريخين insert into #temp (DebitAccount,CreditAccount,BalanceAccount,AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering) (Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,N'رصيد سابق','2020-09-09',1 From DayBook Where AccountDate < '2020-09-10' And AccountID=1811 group by AccountID,AccountName) -- جلب سجل الرصيد و معلوماته select * from #temp -- دمج النتيجتين الخاصتين بكشف الحساب UNION ALL -- إستعلام البحث عن حساب بين تاريخين Select Sum(DebitAccount)As DebitAccount,Sum(CreditAccount)As CreditAccount,Sum(DebitAccount)-Sum(CreditAccount)As BalanceAccount,AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering From DayBook Where AccountDate Between '2020-09-10' And '2021-04-15' And AccountID=1811 group by AccountID,AccountName,AccountStatement,AccountDate,AutoNumbering;
انا عارف ان تعبتك والله وبصراحه مظبطتش معايا ممكن مثال بقاعده بينانت بسيطه اكسس فيها شويه سجلات بتواريخ مختلفه يكون فيها رصيد سابق ويكمل على باقى السجلات بين تاريخين ويبقى جزاك الله الف خير
المشاركات : 2,329
المواضيع 81
الإنتساب : May 2018
السمعة :
522
الشكر: 14039
تم شكره 5671 مرات في 2269 مشاركات
أخي العزيز هذه الاكواد هي لا تصلح لقواعد البيانات أكسيس هي مخصصة لقواعد البيانات SQL Server فأكود الاكسيس مختلفة كليا عن هذه الاكواد و الله الموفق .
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
|