Advertisement
Guest User

Srijon

a guest
Jan 20th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. select distinct jobTypeID='1',j.InvoiceDate as IssueDate,j.InvoiceDate as EntryDateTime, 'New Installation Request' as Subject,
  2. j.CustomerID,bp.Name CustomerName,bp.OwnerMobile CustomerPhone,bp.DateOfBirth CustomerDOB,
  3. bp.NationalID CustomerNID,bp.Gender,j.ShowroomID DealerID,j.LandMark,j.RoadNo,j.HouseNo,j.CPE,j.PackageId servicePackageID,
  4. j.SubscriberId,sss.SerialNo STBnumber,j.InvoiceID ReferenceID,1 as ReferenceType,j.CreatedBy,
  5. j.InvoiceDate CreatedDate,T.DistributorID
  6. from SalesInvoice j
  7. INNER JOIN
  8. (Select ThanaID,DistributorID=MAX(DistributorID) from BusinessPartnerLocation bpl Group by ThanaID) T ON j.ThanaId=T.ThanaID
  9. INNER JOIN InvoiceLineItem AS ili ON j.InvoiceID= ili.InvoiceID
  10. INNER JOIN InvoiceLineItemSerial AS ilis ON j.InvoiceID=ilis.InvoiceID AND ili.InvoiceLineItemID=ilis.InvoiceLineItemID
  11. INNER JOIN skubatchstockserial AS sss ON sss.SKUSerialID=ilis.SerialID AND sss.SKUBatchID=ilis.SKUBatchID
  12. LEFT Join BusinessPartner bp on j.CustomerID=bp.BPID and bp.Category=11
  13. where cast(j.CreatedDate as Date)>=cast('19 Jan 2020' as Date)
  14. and j.SubscriberId not in (
  15. select distinct j.SubscriberId from job j where cast(j.CreatedDate as Date)>=cast('19 Jan 2020' as Date)
  16. and j.SubscriberId is not null)
  17. and T.DistributorID>0
  18. and sss.SerialStatus=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement