please help to select these rows from these tables my tables are
table1
table1Id groupId table2id price
1 1 1 10
2 1 3 1000
3 1 4 500
4 2 1 5
5 2 3 1000
6 2 2 2000
table2
table2id name
1 hello
2 test
3 test1
4 test2
ok i want to select maximum priced row from table1 grouped by groupid
with table2id and table2.name
my out put is
groupid price table2id table2.name
1 1000 3 test1
2 2000 2 test
if i do :
select groupid,max(tab le1.price) as price from table1 group by price
this will give me the max priced row from table1
but when i join them with the table2 it gives me all rows
like
Select groupid,max(pri ce) as price,table2id, table2.name from table1
inner join on table2
group by groupid,table2i d,table2.name
it gives me all rows cause i had to group by table2.id and table2.name
but i can't take it out cause it give me no aggrigated value error
i can't figure out any other way, please help
SQL Server 2000
thanks
eric
table1
table1Id groupId table2id price
1 1 1 10
2 1 3 1000
3 1 4 500
4 2 1 5
5 2 3 1000
6 2 2 2000
table2
table2id name
1 hello
2 test
3 test1
4 test2
ok i want to select maximum priced row from table1 grouped by groupid
with table2id and table2.name
my out put is
groupid price table2id table2.name
1 1000 3 test1
2 2000 2 test
if i do :
select groupid,max(tab le1.price) as price from table1 group by price
this will give me the max priced row from table1
but when i join them with the table2 it gives me all rows
like
Select groupid,max(pri ce) as price,table2id, table2.name from table1
inner join on table2
group by groupid,table2i d,table2.name
it gives me all rows cause i had to group by table2.id and table2.name
but i can't take it out cause it give me no aggrigated value error
i can't figure out any other way, please help
SQL Server 2000
thanks
eric
Comment