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 |
|
chiman
21 Posts |
Posted - 2007-11-12 : 16:16:10
|
| hi,I have a query like below,select max(batchNumber ) from Adjustments where store_Id = 8637Unionselect max(batchnumber) from batch binner join Document d on d.Document_Id = b.General_Id and b.BatchType <> 'Warehouse' and b.TranTable='Document'This gives me 2 rows,how ever i want the max on the result of this union.Assume, the above returns 1020i want 20.how to go about this?Thanks |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-11-12 : 16:28:14
|
| [code]select max(batchNumber)from( select max(batchNumber) as batchNumber from Adjustments where store_Id = 8637 union all select max(batchnumber) from batch b inner join Document d on d.Document_Id = b.General_Id where b.BatchType <> 'Warehouse' and b.TranTable = 'Document') t[/code]Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
chiman
21 Posts |
Posted - 2007-11-12 : 16:29:34
|
| Thanks a lot. This worked! |
 |
|
|
|
|
|