[GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Nick
I have three tables (users, books, pencils) and would like to get a list of all users with a count and total price of their books and pencils for 2012-01-01... So with this data... users (user_id) 1 2 3 books (user_id, price, created) 1 | $10 | 2012-01-01 1 | $10 | 2012-01-01 3 | $10 |

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Tom Molesworth
Hi Nick, On 17/01/12 00:18, Nick wrote: I have three tables (users, books, pencils) and would like to get a list of all users with a count and total price of their books and pencils for 2012-01-01... So with this data... users (user_id) 1 2 3 books (user_id, price, created) 1 | $10 |

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Nick
On Jan 17, 3:33 am, t...@audioboundary.com (Tom Molesworth) wrote: Hi Nick, On 17/01/12 00:18, Nick wrote: I have three tables (users, books, pencils) and would like to get a list of all users with a count and total price of their books and pencils for 2012-01-01... So with

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Nick
On Jan 17, 3:33 am, t...@audioboundary.com (Tom Molesworth) wrote: Hi Nick, On 17/01/12 00:18, Nick wrote: I have three tables (users, books, pencils) and would like to get a list of all users with a count and total price of their books and pencils for 2012-01-01... So with

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Nick
On Jan 17, 3:33 am, t...@audioboundary.com (Tom Molesworth) wrote: Hi Nick, On 17/01/12 00:18, Nick wrote: I have three tables (users, books, pencils) and would like to get a list of all users with a count and total price of their books and pencils for 2012-01-01... So with

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Nick Sent: Tuesday, January 17, 2012 12:59 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Whats the most efficient query for this result? On Jan 17, 3:33 am, t

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread Tom Molesworth
On 17/01/12 17:51, Nick wrote: On Jan 17, 3:33 am, t...@audioboundary.com (Tom Molesworth) wrote: Hi Nick, On 17/01/12 00:18, Nick wrote: What is the most efficient way to get this result... query_result (user_id, book_count, book_price_total, pencil_count, pencil_price_total) 1 | 2 | $20 |

Re: [GENERAL] Whats the most efficient query for this result?

2012-01-17 Thread David Johnston
On Jan 17, 2012, at 21:08, Tom Molesworth t...@audioboundary.com wrote: On 17/01/12 17:51, Nick wrote: On Jan 17, 3:33 am, t...@audioboundary.com (Tom Molesworth) wrote: Looking at it again, I think the missing part is the created fields - you'll probably need both of those in the group by