数据库查询从微型POS 3700获取订购商品?

时间:2014-05-22 07:43:29

标签: database

- >首位订单

按顺序添加4项

- >从pos

删除(无效)1项

- >仍然它回复了无效项目数量为X 3的订单商品

现在,我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

这可能会得到你所需要的...... 您会注意到空隙显示为负数量和负数量。如果你要适当地对你的sql中的项目进行分组,你可以总结并获得空位来取消原来的费用。

   SELECT coalesce(Maj.name_1,'') as Department, 
          coalesce(Fam.name_1,'') as Category, 
          coalesce(mi.Name_1,'') as ItemDescription,
          coalesce(dtl.Seat,0) as Seat, 
          coalesce(dtl.chk_cnt, 0) as chk_cnt,
          coalesce(dtl.chk_ttl, 0.00) as chk_ttl
   FROM micros.v_dtl dtl with(nolock)
   left outer join micros.chk_dtl cd with(Nolock) on cd.chk_seq = dtl.chk_seq
   left outer join micros.emp_def empDef with(Nolock) on empDef.Emp_Seq = cd.Emp_Seq
   left outer join micros.mi_def mi on mi.mi_seq=M_mi_Seq
   left outer join micros.v_maj_grp_def maj on maj.seq = mi.maj_grp_seq
   left outer join micros.v_fam_grp_def fam on fam.seq = mi.fam_grp_seq
   left outer join MICROS.trans_dtl TRANS on TRANS.trans_seq = DTL.trans_seq
   where dtl.dtl_type in ('M','D') and 
   trans.business_date = '2015-04-23 00:00:00.000' and --business date of sales
   cast(cd.Chk_num as varchar(20)) = 000 --USE THE REAL TICKET # HERE
   order by dtl.chk_seq, dtl.trans_seq, dtl.dtl_seq