Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 derived column or join?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-10 : 06:42:01
Travis writes "Fair warning I am a rookie when it comes to sql..... Here is my situation, two tables, one with 6 columns(small table) and one with say 30+(big table). Smalll table and big table have a parent child relationship. Small table is expecting lots of searches and use. Big table with multiple records for each of small tables will be far far lighter. Save for one issue. I need to get the sum() of multiple records of big table and have them fill a field for each record of the small table....

My question is this. What is the best way to accomplish this situation. I was thinking a subQuery, but am not sure if thats more efficient than a join or a triger and static field. Oh and its very late so I hope this all makes sense... Thanks a bundle."

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-06-10 : 13:59:09
Can you post some code for us?

This would help us out a lot:

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2005-06-10 : 15:14:42

I think this is what your after


Select Smalltable.ID, Sum(largetable.column1) as whatever
From Smalltable inner join largetable on Smalltable.ID = largetable.ID
Group by Smalltable.ID

Jim
Users <> Logic
Go to Top of Page
   

- Advertisement -