Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP 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 January 27th, 2004, 06:50 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default group by problem

I have two tables in the database named orders and colorchart
orders:
    1.indexno(PK)
    2.job_code
    3.shipMode
    4.exportDate
    5.sizeCode

colorchart:
    1.indexno(FK)
    2.colorCode
    3.Qty

I want to retrieve a data as

All fields from the orderstable and sum(qty) from the colorchart for each indexno match.

What is the query.

I have given as

select o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode,sum(cc.qty) as Qty from orders o,colorchart cc group by o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode having o.indexno=cc.indexno order by o.indexno

Displaying error "Tried to execute a query that does not include the specified expression o.indexno=cc.indexno as part of aggregate function"

When i give where clause instead of having its executing fine. But having is to be used with group by clause. The query is as...

select o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode,sum(cc.qty) as Qty from orders o,colorchart cc where o.indexno=cc.indexno group by o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode order by o.indexno





 
Old January 27th, 2004, 08:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Change it to a join:

SELECT o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode,SUM(cc.qty) as Qty
FROM orders o INNER JOIN colorchart cc
ON o.indexno=cc.indexno
GROUP BY o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode
ORDER BY o.indexno





Similar Threads
Thread Thread Starter Forum Replies Last Post
"Group by" problem dani1 XSLT 2 October 30th, 2008 03:21 PM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group By Problem [email protected] SQL Language 2 December 9th, 2004 12:42 PM
Report problem in group by mateenmohd Access 3 May 24th, 2004 12:16 AM
Query Problem group by mateenmohd SQL Server 2000 4 February 4th, 2004 02:44 AM





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