Gossamer Forum
Home : Products : DBMan SQL : Discussion :

grouping related tables

Quote Reply
grouping related tables

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:
Author: id, name
Book: id, author_id, title, price
And I want the following query:
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?


Subject Author Views Date
Thread grouping related tables jaspercram 2591 Dec 17, 2002, 1:00 AM
Thread Re: [jaspercram] grouping related tables
hennagaijin 2528 Dec 17, 2002, 4:36 AM
Post Re: [hennagaijin] grouping related tables
jaspercram 2199 Dec 18, 2002, 7:36 AM