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 2005 Forums
 Transact-SQL (2005)
 Query

Author  Topic 

sam_sh
Starting Member

4 Posts

Posted - 2009-10-07 : 15:14:03
Hi
I have 3 tables:
T1
ID Name
-------
1 A
2 B

T2
ID Date p
-------------------
1 2008/01/02 20
2 2009/05/15 15

T12
IDT1 IDT2 d
-------------
1 1 7
1 2 5
2 2 3
2 2 8

result between 2 date :
Name d*p as expr1
-------------------------
A (7*20)+(5*15)=215
B (3*20)+(8*15)=180

thanks

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-10-07 : 16:31:09
Really tough to decipher your question. Read this link and post the necessary info:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Be One with the Optimizer
TG
Go to Top of Page

matrixmind
Starting Member

9 Posts

Posted - 2009-10-30 : 02:56:42
quote:
Originally posted by sam_sh

Hi
I have 3 tables:
T1
ID Name
-------
1 A
2 B

T2
ID Date p
-------------------
1 2008/01/02 20
2 2009/05/15 15

T12
IDT1 IDT2 d
-------------
1 1 7
1 2 5
2 2 3
2 2 8

result between 2 date :
Name d*p as expr1
-------------------------
A (7*20)+(5*15)=215
B (3*20)+(8*15)=180

thanks






with abc
as
(
select IDT1,IDT2,D,P
From TC1TC2 PC inner join CT2 C2
on C2.ID=PC.IDT2
)
select Sum(D*P) as [Exp1],CT1.Name from abc inner join CT1 on CT1.ID=Abc.IDT1
Group by CT1.Name

Dinesh Sharma
Matrix Solution
Sr.Software Engg.
Go to Top of Page
   

- Advertisement -