Tpaul_10
asked on
Neeq a SQL query
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I presume you need to review the specs ... because I don't see an explanation why table2 is actually needed, and I see no explanation on why row2 from table1 is returned and why not row1.
meanwhile, you might want to read this article, I presume it will help you:
https://www.experts-exchange.com/A_3203.html
meanwhile, you might want to read this article, I presume it will help you:
https://www.experts-exchange.com/A_3203.html
My mistake
select MAX(A.Column1) [Table1 Column1], B.Column1 [table2 Column1], MAX(A.Column3) [Column3]
from Table1 A
inner join Table2 B on B.Column1 = A.Column2
group by B.Column1
select MAX(A.Column1) [Table1 Column1], B.Column1 [table2 Column1], MAX(A.Column3) [Column3]
from Table1 A
inner join Table2 B on B.Column1 = A.Column2
group by B.Column1
ASKER
Basically I need the max value from table1 and for some rows, it is returning the both the rows even though I have used max(column1) in my query. Not sure why
Thanks
Thanks
ewangoya,
We don't know why he is selecting one row over the other - maybe it should be max, maybe min, maybe first, maybe last ... :-)
Ss
We don't know why he is selecting one row over the other - maybe it should be max, maybe min, maybe first, maybe last ... :-)
Ss
A quick look at the results tells me its max values
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all your help guys and just to let you know I don't have to review my specs since it was pretty straight forward and I didn't specify all the columns in my tables and I wanted the maximum value.
Sharath's solution gave me the correct results. once again THANKS to all for quick response.
Sharath's solution gave me the correct results. once again THANKS to all for quick response.
Ss