MS Sql Query
Posted on 2009-04-06
I have a table called RestChist and need to pull the following feilds:
CK_CHECKNO, CK_STATUS, CK_COVERS, CK_TIP, CK_DISCOUNT, CK_FOOD, CK_BEVG, CK_BEER, CK_WINE, CK_LIQUOR, CK_OTHER , CK_TAX and RESTNO
But, I need to do a distinct count on the CK_CHECKNO to give me a count of how many checks by the server
Sum CK_FOOD+CK_BEVG+CK_BEER+CK_WINE+CK_LIQUOR+CK_OTHER as "Items Sold"
sum the "items Sold" along with tips, tax minus discounts to get "total"
What I need is to get something like the following
Server No. of Checks Items Sold Tax Tips Discounts Total
1 10 $100 $10 $15 $5 $120
2 5 $75 $7.50 $20 $0 $102.50