If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Query help with receipts

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-09, 00:02
StealthRT StealthRT is offline
Registered User
 
Join Date: Jul 2003
Posts: 45
Question Query help with receipts

Hey all I am in need of some help with my query. I am testing this out with 2 users. However, it only seems to show the first user and never the other one. Here is my query string.
Code:
SELECT productr.id, staybridgedb.productr.itemPrice, productr.itemName,

SUM(productr.itemsSold) AS ITEMSSOLD,
SUM(productr.itemPriceTotal) AS PRICETOTAL,
SUM(productr.transactTotal) AS TRANSTOTAL,
SUM(productr.itemTax) AS TAX,
SUM(productr.transactTotalTax) AS TOTALWITHTAX,

productr.empID, staybridgedb.productr.transTime,
productr.itemRUDate, staybridgedb.empid.UniqueID,
empid.FName, staybridgedb.empid.LName
FROM productr, empid
WHERE productr.empid = empid.UniqueID
AND itemRUDate >= '2009/09/03'
GROUP BY itemName DESC
It displays fine for the first user but never shows anything for the second user. And i've also checked to make sure the "UniqueID" is different for both of them and that it has the same dates "2009/09/03" when looking through the receipts.

Any help would be great!

David
Reply With Quote
  #2 (permalink)  
Old 09-15-09, 02:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
your problem is due to improper grouping

you did not describe your tables, or how/why the employee is related to the product

therefore it's not possible to guess whether you wanted product totals for each employee or employee totals for each product
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-15-09, 18:56
StealthRT StealthRT is offline
Registered User
 
Join Date: Jul 2003
Posts: 45
Ive solved it by just using the ID in both cases to insure it would go through.
Code:
SELECT itemname, itemsSold, empid, itemRUDate, itemPrice, itemPriceTotal, recpType, itemTransID,
transTime, staybridgedb.empid.FName, staybridgedb.empid.LName
From staybridgedb.productr, staybridgedb.empid
WHERE productr.empid = '" & theUID & "'
AND staybridgedb.empid.UniqueID = '" & theUID & "'
AND itemRUDate = '2009/09/03'
ORDER BY itemTransID, itemName ASC
But thanks for the pointer!

David
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On