SQL Query for Multiplication

Viewed 33475

I have two relations(tables in SQL Database) having purely numbers. These two relations are to be imagined as Matrices.

The Question is to write an SQL query to multiply there two relations as we do with normal matrix multiplication.

I have been racking my brains for this.... But to no use :O

Can anyone please help me out?????

Table number 1 : enter image description here

@ Aaron Bertrand :

I am using SQL Server 2008 R2 The Screenshots of the tables are :

Table 1 :

enter image description here

Table 2 :

enter image description here

I used the Query :

select t1.A,t2.B,SUM(t1.C*t2.C)
from Table_1 as t1 join Table_2 as t2 on t1.B=t2.A 
group by t1.A,t2.B   
order by t1.A

The Answer :

enter image description here

This way is quite Easy rather than my original Matrix way as suggested by @Marcelo Cantos and @ypercube...

2 Answers
Related