how to solve this problem calculation.

Jul 22 2017 5:13 AM
dear all,
 
please help me,
 
i have two table one is InicialStockMedicine and another table is MedicineDispatch.
 
inicialstockmedicine field:
 
@IniMediSckId VARCHAR=NULL,
@MedecinId VARCHAR=NULL,
@MedicineStockDate VARCHAR=NULL,
@Balance VARCHAR=NULL
  and
 MedicineDispatch:
@MediDisPatchId VARCHAR=NULL,
@MedecinId VARCHAR=NULL,
@MediDisPatchDate VARCHAR=NULL,
@MediDistribuId VARCHAR=NULL,
@DispatchBalance VARCHAR=NULL,
@Remarks VARCHAR=NULL,
@CreationId VARCHAR=NULL,
@ModifiedId VARCHAR=NULL,
@InicialStockBl VARCHAR=NULL,
 @MedicineDisName varchar=null
 
 
 
how this solve i want insicialstockbl from reduce dispatchtable balance in sql server.
 
my store procedure :
 
 
 
ALTER PROCEDURE [dbo].[GET_STOCK_MEDICINE_DISPATCH_INFORMATION_GRID_SP]

--exec GET_STOCK_MEDICINE_DISPATCH_INFORMATION_GRID_SP '5','5','7/02/2017','0','ddd','1','1','3','36'

@MediDisPatchId VARCHAR=NULL,
@MedecinId VARCHAR=NULL,
@MediDisPatchDate VARCHAR=NULL,
@MediDistribuId VARCHAR=NULL,
@DispatchBalance VARCHAR=NULL,
@Remarks VARCHAR=NULL,
@CreationId VARCHAR=NULL,
@ModifiedId VARCHAR=NULL,
@InicialStockBl VARCHAR=NULL

AS

SELECT MedicineDispatch.MediDisPatchId,MedicineDispatch.MedecinId,MedicineDispatch.MediDisPatchDate,MedicineDispatch.MediDistribuId,

MedicineDispatch.Remarks,MedicineDispatch.CreationId,MedicineDispatch.ModifiedId,MedicineDispatch.MedicineDisName,MedicineDispatch.ModifiedId,MedicineDispatch.InicialStockBl

FROM MedicineDispatch

INNER JOIN MedecinMST on MedicineDispatch.MedecinId= MedecinMST.MedecinId
INNER JOIN MedecineDistribution on MedicineDispatch.MediDistribuId=MedecineDistribution.MediDistribuId
INNER JOIN InicialStockMedicine ON MedicineDispatch.InicialStockBl=InicialStockMedicine.Balance

GROUP BY MedecinMST.MedecinId,MedecinName
 
 
how to calculation .please anyone solve this problem .
 
 

Answers (4)