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
 Transact-SQL (2000)
 Help with query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-02 : 07:25:42
marmar writes "Hi

I need help with a query. I have two tables that looks the same:

table 1
var1
var2
var3
var4

table 2
var1
var2
var3
var4

What I want to do is group and order by var2, var3 and var4 and do a count(table1.var1)+ count(table2.var1)/2 (a mean) for the same groups. I'm not sure how to do this. Any suggestions ?

Thanks in advance !"

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-02 : 07:31:33
Not sure what you want.

select table1.var2, table1.var3, table1.var4 , (1.0 * count(table1.var1)+ count(table2.var1))/2
from table1 join table2
on table1.var2 = table2.var2 and table1.var3 = table2.var3 and table1.var4 = table2.var3
group by table1.var2, table1.var3, table1.var4


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -