网上订单_查看_下一笔_打印.sql 1.5 KB

123456789101112131415161718192021
  1. Declare @StartNo nvarchar(64)
  2. Declare @EndNo nvarchar(64)
  3. Set @StartNo='IBN201904010003'
  4. Set @EndNo='IBN201904010003'
  5. SELECT IndentBillOnNet.*, Customer.No_Customer, Customer.Name_Customer, Customer.ShortName_Customer, Customer.Type_Customer,
  6. Customer.LastDiscount_Customer, Customer.PostalCode_Customer, ISNULL(b.Name_User, '') AS Name_Assessor, Customer.ID_Creator As CustomerCreator
  7. FROM IndentBillOnNet
  8. LEFT JOIN Customer ON Customer.ID_Customer = IndentBillOnNet.ID_Customer
  9. LEFT JOIN AppUser b ON b.ID_User = IndentBillOnNet.ID_Assessor
  10. WHERE No_IndentBillOnNet >= (case DataLength(@StartNo) When 0 Then No_IndentBillOnNet Else @StartNo End) And No_IndentBillOnNet <= (case DataLength(@EndNo) When 0 Then No_IndentBillOnNet Else @EndNo End)
  11. SELECT IndentBillOnNetProduct.*,No_IndentBillOnNet,Product.No_Product, Product.Name_Product, Product.Unit_Product,
  12. (IndentBillOnNetProduct.Quantity_IndentBillOnNetProduct * IndentBillOnNetProduct.UnitPrice_IndentBillOnNetProduct) AS Amount_IndentBillOnNetProduct ,No_IndentBillOnNet
  13. FROM IndentBillOnNetProduct
  14. LEFT JOIN Product ON Product.ID_Product = IndentBillOnNetProduct.ID_Product
  15. Left Join IndentBillOnNet On IndentBillOnNet.ID_IndentBillOnNet = IndentBillOnNetProduct.ID_IndentBillOnNet
  16. WHERE No_IndentBillOnNet >= (case DataLength(@StartNo) When 0 Then No_IndentBillOnNet Else @StartNo End) And No_IndentBillOnNet <= (case DataLength(@EndNo) When 0 Then No_IndentBillOnNet Else @EndNo End)