Hello gentlemen.
I have gone from gray'ed haired trying to figure this out. I am simply retrieving check level info and detail level info for each check and expect the sum of charges on the lineitem record to be = to some value in the chk_dtl table, i would expect subtotal. However virtually none of them line up. As a side note in case it matters, at least on menuitem refered to in the mi_dtl table is not in the mi_def.
this is my query:
========================
select chk_dtl.chk_num as CheckID, dtl.dtl_seq as LineItem, isnull(mi_def.obj_num,0) as plu, dtl.rpt_cnt as Quantity, dtl.chk_ttl as SalesValue,
CONVERT(CHAR(23), CONVERT(DATETIME, dtl.date_time, 101), 120) AS CheckItemTime, dtl.seat as SeatID ,ISNULL(mi_dtl.parent_dtl_seq, 0) AS ParentLineItem
,dtl.dtl_name,
SUM(dtl.chk_ttl) OVER() AS SumLineItems,
chk_dtl.sub_ttl AS CheckTotal,
chk_dtl.tax_ttl AS TaxTotal,
chk_dtl.pymnt_ttl AS CheckTotalal
from dtl
join trans_dtl on dtl.trans_seq = trans_dtl.trans_seq
join chk_dtl on trans_dtl.chk_seq = chk_dtl.chk_seq
join mi_dtl on (dtl.trans_seq=mi_dtl.trans_seq and dtl.dtl_seq=mi_dtl.dtl_seq)
left outer join mi_def on mi_dtl.mi_seq = mi_def.mi_seq
where chk_dtl.chk_num = 3291
and dtl_type='M'
order by checkID, Lineitem
====================================================
and gives the following results:
====================================================
CheckID LineIte plu Quantity SalesValue CheckItemTime SeatID ParentLineItem dtl_name SumLineItems CheckTotal TaxTotal CheckTotalal
3291 1 10001 1 8.75 2015-05-17 15:19:52 1 0 CARROT CAKE 158.48 140.98 11.28 152.26
3291 1 5006 1 46.99 2015-05-17 14:08:50 1 0 BRUNCH $ 46.99 158.48 140.98 11.28 152.26
3291 2 5006 1 46.99 2015-05-17 14:08:50 1 0 BRUNCH $ 46.99 158.48 140.98 11.28 152.26
3291 2 10002 1 8.75 2015-05-17 15:19:52 1 0 CHOC MOUSSE 158.48 1410.98 11.28 152.26
3291 3 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 4 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 5 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 6 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 7 80016 1 0 2015-05-17 14:08:50 1 6 SPEC PREP 158.48 140.98 11.28 152.26
Note the 4 columns on the right included to show chk totals according to chk_dtl. None of them match the 158.48 which the items add up to. So it is hard to reconcile.
the 4 tables involved to make it clear:
==============================================
Mi_dtl:
trans_seq dtl_seq mi_seq obj_num
1229898 5 10953 200115
1229898 7 4292 80016
1229898 1 8611 5006
1229898 3 10953 200115
1230052 1 6408 10001
1230052 2 8643 10002
1229898 2 8611 5006
1229898 4 10953 200115
1229898 6 10953 200115
Dtl:
trans_seq dtl_seq chk_ttl dtl_id dtl_name
1229898 1 46.99 17 BRUNCH $ 46.99
1229898 2 46.99 18 BRUNCH $ 46.99
1229898 3 11.75 19 ULT ACAI CAIP.
1229898 4 11.75 20 ULT ACAI CAIP.
1229898 5 11.75 21 ULT ACAI CAIP.
1229898 6 11.75 22 ULT ACAI CAIP.
1229898 7 0 23 SPEC PREP
1230052 1 8.75 25 CARROT CAKE
1230052 2 8.75 26 CHOC MOUSSE
Trans_dtl:
trans_seq type chk_seq
1229898 S 180769
1230052 S 180769
1230054 S 180769
1230086 S 180769
1230114 S 180769
1230128 S 180769
chk_dtl:
chk_seq chk_num sub_ttl tax_ttl pymnt_ttl
180769 3291 140.98 11.28 152.26
None of the trans amounts add uo to the check and the item ULT ACAI CAIP. is not in the mi_def table at all.
Any pointers would be greatly appreciated.
Thank you
I have gone from gray'ed haired trying to figure this out. I am simply retrieving check level info and detail level info for each check and expect the sum of charges on the lineitem record to be = to some value in the chk_dtl table, i would expect subtotal. However virtually none of them line up. As a side note in case it matters, at least on menuitem refered to in the mi_dtl table is not in the mi_def.
this is my query:
========================
select chk_dtl.chk_num as CheckID, dtl.dtl_seq as LineItem, isnull(mi_def.obj_num,0) as plu, dtl.rpt_cnt as Quantity, dtl.chk_ttl as SalesValue,
CONVERT(CHAR(23), CONVERT(DATETIME, dtl.date_time, 101), 120) AS CheckItemTime, dtl.seat as SeatID ,ISNULL(mi_dtl.parent_dtl_seq, 0) AS ParentLineItem
,dtl.dtl_name,
SUM(dtl.chk_ttl) OVER() AS SumLineItems,
chk_dtl.sub_ttl AS CheckTotal,
chk_dtl.tax_ttl AS TaxTotal,
chk_dtl.pymnt_ttl AS CheckTotalal
from dtl
join trans_dtl on dtl.trans_seq = trans_dtl.trans_seq
join chk_dtl on trans_dtl.chk_seq = chk_dtl.chk_seq
join mi_dtl on (dtl.trans_seq=mi_dtl.trans_seq and dtl.dtl_seq=mi_dtl.dtl_seq)
left outer join mi_def on mi_dtl.mi_seq = mi_def.mi_seq
where chk_dtl.chk_num = 3291
and dtl_type='M'
order by checkID, Lineitem
====================================================
and gives the following results:
====================================================
CheckID LineIte plu Quantity SalesValue CheckItemTime SeatID ParentLineItem dtl_name SumLineItems CheckTotal TaxTotal CheckTotalal
3291 1 10001 1 8.75 2015-05-17 15:19:52 1 0 CARROT CAKE 158.48 140.98 11.28 152.26
3291 1 5006 1 46.99 2015-05-17 14:08:50 1 0 BRUNCH $ 46.99 158.48 140.98 11.28 152.26
3291 2 5006 1 46.99 2015-05-17 14:08:50 1 0 BRUNCH $ 46.99 158.48 140.98 11.28 152.26
3291 2 10002 1 8.75 2015-05-17 15:19:52 1 0 CHOC MOUSSE 158.48 1410.98 11.28 152.26
3291 3 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 4 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 5 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 6 0 1 11.75 2015-05-17 14:08:50 1 0 ULT ACAI CAIP. 158.48 140.98 11.28 152.26
3291 7 80016 1 0 2015-05-17 14:08:50 1 6 SPEC PREP 158.48 140.98 11.28 152.26
Note the 4 columns on the right included to show chk totals according to chk_dtl. None of them match the 158.48 which the items add up to. So it is hard to reconcile.
the 4 tables involved to make it clear:
==============================================
Mi_dtl:
trans_seq dtl_seq mi_seq obj_num
1229898 5 10953 200115
1229898 7 4292 80016
1229898 1 8611 5006
1229898 3 10953 200115
1230052 1 6408 10001
1230052 2 8643 10002
1229898 2 8611 5006
1229898 4 10953 200115
1229898 6 10953 200115
Dtl:
trans_seq dtl_seq chk_ttl dtl_id dtl_name
1229898 1 46.99 17 BRUNCH $ 46.99
1229898 2 46.99 18 BRUNCH $ 46.99
1229898 3 11.75 19 ULT ACAI CAIP.
1229898 4 11.75 20 ULT ACAI CAIP.
1229898 5 11.75 21 ULT ACAI CAIP.
1229898 6 11.75 22 ULT ACAI CAIP.
1229898 7 0 23 SPEC PREP
1230052 1 8.75 25 CARROT CAKE
1230052 2 8.75 26 CHOC MOUSSE
Trans_dtl:
trans_seq type chk_seq
1229898 S 180769
1230052 S 180769
1230054 S 180769
1230086 S 180769
1230114 S 180769
1230128 S 180769
chk_dtl:
chk_seq chk_num sub_ttl tax_ttl pymnt_ttl
180769 3291 140.98 11.28 152.26
None of the trans amounts add uo to the check and the item ULT ACAI CAIP. is not in the mi_def table at all.
Any pointers would be greatly appreciated.
Thank you