Micros.trans_dtl is the main transaction table that will link transactions to checks, employees and RVC's.
Micros.sale_dtl holds order type and itemizer sales by transaction. Join it to micros.trans_dtl on the common field trans_seq.
Drilling in further needs an extra table link. Micros.dtl holds the details for each entry within a transaction. This also joins to micros.trans_dtl on the common field trans_seq.
You can join micros.dtl to the menu item (mi_dtl), discount/service charge, (dsvc_dtl) and payment, (tmed_dtl) details on the common fields trans_seq and dtl_seq. This will give you strictly numbers and codes. If you need the item names you'll have to also join the definition tables.
So, to get menu item details you would use something like this.
Code:
select * from
micros.trans_dtl as tdtl join
micros.dtl as d on
tdtl.trans_seq = d.trans_seq join
micros.mi_dtl as mdtl on
d.trans_seq = mdtl.trans_seq and
d.dtl_seq = mdtl.dtl_seq join
micros.mi_def as mdef on
mdtl.mi_seq = mdef.mi_seq
Extracting details for multiple item types can get a bit tricky. Using inner joins to get both menu item and payment totals for instance will return nothing. The trans_seq/dtl_seq combos will have cancelled each other out. Use either individual queries or union a bunch together. The detail queries can get pretty labor intensive, so using one monster query with outer joins will work but it can bog down the server.
Last, remember that micros details are only held for 14 days. I don't usually trust the data from the earliest day in these tables. The data purge is hardcoded at 14 days, so if it's run mid shift you'll only have partial data for the earliest detail date.
Hope this helps,
Pat