Subject | Re: [firebird-support] Re: join aggregate query to table |
---|---|
Author | Jason Dodson |
Post date | 2005-11-08T14:54:04Z |
Just a word of advice. It never pays to be lazy about SQL syntax. Include an
explicit "Inner Join" rather than just "Join", if that is what you mean to do.
It will only save you headaches in the end. A lot of us can speak from experience.
Jason
Svein Erling Tysvær wrote:
explicit "Inner Join" rather than just "Join", if that is what you mean to do.
It will only save you headaches in the end. A lot of us can speak from experience.
Jason
Svein Erling Tysvær wrote:
> I think there is something I don't see. To me, it looks like it should
> simply be a minor change to your existing query:
>
> select customer.name, sales.sales_id, sum(payments.allocated_amount)
> from sales
> join payments on sales.sales_id = payments.sales_id
> join customer on sales.customer_id = customer.customer_id
> group by customer.name, sales.sales_id
>
> Maybe you would want to use LEFT JOIN rather than JOIN (in case some
> sales doesn't include a customer). The only way this would fail is if
> customer.customer_id is not unique.
>
> HTH,
> Set
>
> -I support Firebird, I am a Firebird Foundation member!
> -Join this weekend at the Firebird Conference in Prague:
> http://www.ibphoenix.com/main.nfs?a=ibphoenix&s=1131440182:209405&page=fb_conference
>
> --- In firebird-support@yahoogroups.com, "msarossy" wrote:
>
>>i need some help with the sql to join an aggregate function to another
>>table.
>>
>>the aggregate query :
>>
>>select sales.sales_id, sum(payments.allocated_amount)
>>from sales join payments
>>on sales.sales_id = payments.sales_id
>>group by sales_id
>>
>>and then this needs to be joined by customer.customer_id to
>>sales.customer_id
>>
>>your help is appreciated
>>
>>marko
>>
>
>
>
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>