Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 16th, 2003, 06:49 AM
Authorized User
Join Date: Jun 2003
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...:)
Old July 16th, 2003, 07:10 AM
Friend of Wrox
Join Date: Jun 2003
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.
Old July 16th, 2003, 07:24 AM
Authorized User
Join Date: Jun 2003
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;

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

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