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.
Author |
Topic |
Gigabyte
Starting Member
30 Posts |
Posted - 2012-06-14 : 19:48:30
|
Table Apid pname1 pen2 pencil3 paperTable Bpid price1 102 253 633 323 442 221 21I need to find pid and price of the product which is the highest among all the products from Table A and Table B GIGABYTE+ |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-14 : 22:40:42
|
[code]SELECT a.pname,n.priceFROM TableA aINNER JOIN TableB bON b.pid = a.pidWHERE b.price = (SELECT MAX(price) FROM tableB)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-06-15 : 00:33:47
|
SELECT TOP(1) WITH TIES a.pname,n.priceFROM TableA aINNER JOIN TableB b ON b.pid = a.pidORDER BY b.price DESC N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|