Gossamer Forum
Home : Products : DBMan SQL : Discussion :

grouping related tables

Quote Reply
grouping related tables
Hi,

In my famous Books and Authors example (each author writes multiple books, each book has one author), the Books table contains a column with the price of the book. Now I want to show a table with for each author the sum of the prices of all books for that author. So I have the following tables:
Code:
Author: id, name
Book: id, author_id, title, price
And I want the following query:
Code:
SELECT a.id, a.name, SUM(b.price)
FROM Author a, Book b
WHERE a.id = b.author_id
GROUP BY a.id, a.name
Is it possible to get these results by only changing the templates? Or do I need to write a plugin?

Jasper

http://www.bookings.org
Subject Author Views Date
Thread grouping related tables jaspercram 3408 Dec 17, 2002, 1:00 AM
Thread Re: [jaspercram] grouping related tables
hennagaijin 3321 Dec 17, 2002, 4:36 AM
Post Re: [hennagaijin] grouping related tables
jaspercram 2992 Dec 18, 2002, 7:36 AM