Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 16th, 2003, 06:49 AM
Authorized User
Join Date: Jun 2003
Location: , , Netherlands.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get this output?


i have 3 tables (clothes, employee and order) in an access db
they have the following attributes (they have more but these are all u need i thought)
clothes: [u]clothid</u>, description, price
employee: [u]employeeId</u>, location
Order: [u]orderid</u>, employeeid, clothid, totalAmount, totalPieces

now i wanna generate a report which is first sorted on location, within that it must be sorted on clothes.description

But when i have multiple orders for the same clothesid i'm getting also more rows for this piece of clothing in my report. All i want is the total per cloth.

I already tried some things with distinct and distinctrow...but somehow that stupid access ain't doing what i want it to do

i hope the text above made sense to anyone...:)
Reply With Quote
  #2 (permalink)  
Old July 16th, 2003, 07:10 AM
Friend of Wrox
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post

Try GROUPing by the clothes.description:
SELECT e.location, c.description, SUM(o.totalAmount)
    FROM employee e
        INNER JOIN Order o ON e.employeeId=o.employeeId
        INNER JOIN clothes c ON o.clothid=c.clothid
GROUP BY e.location, c.description
ORDER BY e.location, c.description;

Jeff Mason
Custom Apps, Inc.
Reply With Quote
  #3 (permalink)  
Old July 16th, 2003, 07:24 AM
Authorized User
Join Date: Jun 2003
Location: , , Netherlands.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts

this is the sql string which stands in access for my report. Sorry for the bad names but i had to translate them from dutch to english

SELECT DISTINCTROW clothes.clothesId, clothes.description, clothes.[price per article], Employee.EmployeeId, Employee.Location, First(order.orderId) AS [First from order_articleId], Sum(order.amount) AS [sum of amount], Sum(order.totalprice) AS [Sum of totalprice], First(order.employeeId) AS [first of order_EmployeeId]
FROM clothes INNER JOIN (Employee INNER JOIN order ON Employee.EmployeeId = order.EmployeeID) ON clothes.clothesid = order.clothesID GROUP BY Employee.Location, clothes.clothesID, clothes.description, clothes.[price per article], Employee.employeeID;
Reply With Quote

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 Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
data output kciwzehc Access 5 November 28th, 2007 01:10 PM
Output to text bonekrusher XSLT 4 November 25th, 2007 01:06 PM
tell me the output abdul_owiusa C# 3 May 10th, 2007 04:25 AM
Output should appear in Mozila instead of IE anujrathi ASP.NET 1.0 and 1.1 Professional 2 August 30th, 2006 09:47 AM
Output Difference wolftrap1 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 January 4th, 2004 05:44 PM

All times are GMT -4. The time now is 06:09 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.