Article View: borland.public.interbase.sql
Article #771Re: Computed fields
From: Wayne Niddery [TeamB]
Date: Thu, 28 Jun 2007 15:04
Date: Thu, 28 Jun 2007 15:04
25 lines
2071 bytes
2071 bytes
Moore wrote: > how can this be done? i do it but it shows me the sum for the first > record in all records, > how to refer to the actual record and actual table in the expression? > can you give an expample? Took me a couple tries to get it right too - but I knew it could be done because I did it successfully years ago. Using the demo Employees database: alter table customer add ordertotal computed by (( select sum(s.total_value) from sales s where s.cust_no = customer.cust_no )) An alias must be used for the table being selected from so the key fields can be distinguished, the trick is that an alias cannot be specified for the table being altered, but you can qualify that table's key with the full table name. -- Wayne Niddery - Winwright, Inc (www.winwright.ca) "Some see private enterprise as a predatory target to be shot, others as a cow to be milked, but few are those who see it as a sturdy horse pulling the wagon." - Winston Churchill
Technical Details
Message-ID:
<4683cdf6$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4680da48@newsgroups.borland.com> <46825418$1@newsgroups.borland.com> <46828329$1@newsgroups.borland.com> <46839253$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,eaa295f7e4d91326 X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> From: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> Newsgroups: borland.public.interbase.sql References: <4680da48@newsgroups.borland.com> <46825418$1@newsgroups.borland.com> <46828329$1@newsgroups.borland.com> <46839253$1@newsgroups.borland.com> Subject: Re: Computed fields Date: Thu, 28 Jun 2007 11:04:24 -0400 Lines: 27 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 69.17.170.228 Message-ID: <4683cdf6$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1183043062 69.17.170.228 (28 Jun 2007 08:04:22 -0700) X-Authenticated-User: wniddery Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail