Hi
in two view i caluculate batch qty and one view issueqty when i select drug and from date two date i want to display the in between dates date batchqty,issueqty ,balanceqty next row i sales some qty
so balance today i enter 100 stock today issued 10 so balance 90 next day i sale one more 20 drugs prevoius balance batchqty 90 issue qty20 balance 70 lime that what problem is suppose i select tommarrow enddate batch qty today i enter so tomarrow batch qty comes zero so balance comes negitive what i want i want to check when i select form date and to date also need to check top 1 batch qtyis>0 that onw wards records need to display
any body can help for th
Thulasiram pakalaPosted Jan 22, 2021, 7:43 AM
From (Select (select top 1 institutename from tblinstitutedetailmaster where instituteid=instid) InstituteName,
kdls.dbo.InstInwardView.wdrugid as drugcode ,Convert(Nvarchar(20),rcptdate,103) as 'recdate',
SUM(isnull(Batchqty,0)) as 'batchqty',0 as 'issueqty', FullDrug=(Select top 1 FullDrug From klem.dbo.vwdrugDetails as drugview
where drugview.drugcode=InstInwardView.wdrugid)
From kdls.dbo.InstInwardView where InstInwardView.instid='002128' and convert(datetime,rcptdate) between '2017-01-01' and '2021-01-01'
and (wdrugid='3.1.1' or '3.1.1' is null) group by instid,rcptdate,kdls.dbo.InstInwardView.wdrugid
UNION ALL
Select (select top 1 institutename from tblinstitutedetailmaster where instituteid=instid) InstituteName,
kdls.dbo .InstOutwardView.oDrugid as drugcode , Convert(Nvarchar(20),oIssueDate,103) as 'recdate', 0 as 'batchqty', SUM(isnull(obatchqty,0)) as 'Issueqty',
FullDrug=(Select top 1 FullDrug From klem.dbo.vwdrugDetails as drugview where drugview .drugcode=InstOutwardView.oDrugid)
From kdls.dbo.InstOutwardView where InstOutwardView.instid='002128'
and convert(datetime,oIssueDate) between '2017-01-01' and '2021-01-01' and (oDrugid='3.1.1' or '3.1.1' is null) group by instid,oIssueDate,kdls.dbo.InstOutwardView.oDrugid
) TBL2
3.1.1 Adrenaline Bitartrate Injection 1mg/ml 1x1ml 17/03/2017 150 0 50
3.1.1 Adrenaline Bitartrate Injection 1mg/ml 1x1ml 30/05/2017 0 -150 150
3.1.1 Adrenaline Bitartrate Injection 1mg/ml 1x1ml 29/08/2017 200 0
3.1.1 Adrenaline Bitartrate Injection 1mg/ml 1x1ml 08/09/2017 0 200
3.1.1 Adrenaline Bitartrate Injection 1mg/ml 1x1ml 06/02/2018 250 0
Amit GuptaPosted Jan 22, 2021, 6:44 AM