Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sum on server with group by clause? 1

Status
Not open for further replies.

anorakgirl

Programmer
Jun 5, 2001
103
GB
Hi,

I have a master table and two child tables. I want to show a sum from one child table and detail from the other.

Say I have the following tables:
Code:
select product.productid, product.name, product_option.description, sum(order_line.quantity) from
product, product_option, order_line
where product.productid = product_option.productid
and product.productid = order_line.productid
group by product.productid, product.name, product_option.description

I'm using Crystal Reports 9 and I can't see how to do this.

I've tried adding an SQL Expression field of sum(order_line) but I can't see how to get Crystal Reports to add the group by clause to the sql query.

And if I do the sum as a summary field in the report, the totals are wrong because order_line rows are returned more than once when there are several product options.

I can't see how to make crystal do this.

I eventually want to be able to pass in some date paramters so I can limit which rows are summed from order_line, which means creating a view which sums over order_line to base it on won't work.

Thanks for your help!










~ ~
 
Check under your database connection and you'll see Add Command, which allowsforpasting in real SQL as the datasource for the report.

Please rememebrtopost your database type in the future.

-k
 
Ah brilliant, I had no idea you could do that! (New to Crystal Reports and just finding my way around).

Sorry, I didn't think the database type was relevant, MS SQL for info.

Thanks again.

~ ~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top