Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> can a field reference the sum of a field in another table?

can a field reference the sum of a field in another table?

From: kaeli <tiny_one_at_NOSPAM.comcast.net>
Date: Fri, 30 Jul 2004 08:09:57 -0500
Message-ID: <MPG.1b7404a02a6d994198a009@nntp.lucent.com>

Hey all,

I'd like to make a table with a field that references the sum of another field in another table. I know I could use a view for this, but it would be more convenient if I could do it right in the table. Is that possible?

Example:
create table tblAttendees (
name varchar2(50) primary key,
regDate date,
seminarId integer references tblSeminars);

create table tblSeminars (
seminarId integer primary key,
seminarName varchar2(50),
maxAttendees integer,
numAttendees integer)

I'd like tblSeminars.numAttendees to be
select count(*) from tblAttendees where tblAttendees.seminarId=tblSeminars.seminarId

Can I do that in the table, or do I need to use a view? Using Oracle 8i on Solaris.

TIA

-- 
--
~kaeli~
Do not taunt Happy Fun Ball! 
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
Received on Fri Jul 30 2004 - 08:09:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US