Re: [SQL] Aggregate question (Sum)

2007-11-19 Thread Luiz K. Matsumura
Hi Rodrigo, thanks for reply Rodrigo De León wrote: On Nov 19, 2007 3:46 PM, Luiz K. Matsumura <[EMAIL PROTECTED]> wrote: If someone can give me some hint I will apreciate. This is more of a normalization problem. See: http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelatio

Re: [SQL] Aggregate question (Sum)

2007-11-19 Thread Rodrigo De León
On Nov 19, 2007 3:46 PM, Luiz K. Matsumura <[EMAIL PROTECTED]> wrote: > If someone can give me some hint I will apreciate. This is more of a normalization problem. See: http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx and lookup Third Normal Form. You have

[SQL] Aggregate question (Sum)

2007-11-19 Thread Luiz K. Matsumura
Hi All, I want to know if there are an easy manner to do an SQL like this bellow where TotalOrdersValue sum the order.total just one time per order (as count(DISTINCT order.id) do) SELECT order.dtorder , Count( DISTINCT order.fk_customer ) AS QtyCustomer , Count( DISTINCT order.id ) AS

Re: [SQL] aggregate question

2003-06-24 Thread Tomasz Myrta
Dnia 2003-06-24 00:04, Użytkownik Tomasz Myrta napisał: select package_name, count(*) as n_packages from packages join package_log using (package_id); And one more: select package_name, sum(case when package_log.package_id is not null then 1 else 0 end) as n_packages from packages left

Re: [SQL] aggregate question

2003-06-24 Thread Hubert Lubaczewski
On Mon, 23 Jun 2003 13:59:52 -0500 (CDT) "Ryan" <[EMAIL PROTECTED]> wrote: > package_id | integer | not null default > I must be a total space case today because I can't hammer out the sql to > get a listing of all the packages with a count() of the package_log by > package_id. if you would

Re: [SQL] aggregate question

2003-06-23 Thread Tomasz Myrta
Dnia 2003-06-23 20:59, Użytkownik Ryan napisał: I know this one is simple enough. I have two tables: packages and package_log. I must be a total space case today because I can't hammer out the sql to get a listing of all the packages with a count() of the package_log by package_id. Thanks, Ryan

[SQL] aggregate question

2003-06-23 Thread Ryan
I know this one is simple enough. I have two tables: packages and package_log. paulsonsoft=# \d packages Table "public.packages" Column | Type |Modifiers -+-+---