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
 General SQL Server Forums
 New to SQL Server Programming
 Regarding UNION Clause for find Max date

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-03-03 : 02:51:11
Dear All,

I used following queary for find the max date from the queary. But it gives error as,
"Incorrect syntax near ')'"

Means union clause queary run propery but i can't able to find tha max date from that.
Can anybody suggest me how to find ?

select Max(D1) from(
select Max(DATE) as D1 From T_BANK_IMPORT_BI Where BANK_CODE = 'HSBC' and ACC_NO = '019144443904'
Union select Max(DATE) as D1 From M_SET_NO_TRANSDATE Where BANK_CODE = 'HSBC' and ACCOUNT_NO = '019144443904')

Thanks and Regards
Harish Patil

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-03-03 : 03:19:06
you just need to alias your derived table....
select Max(D1) from(
select Max(DATE) as D1 From T_BANK_IMPORT_BI Where BANK_CODE = 'HSBC' and ACC_NO = '019144443904'
Union select Max(DATE) as D1 From M_SET_NO_TRANSDATE Where BANK_CODE = 'HSBC' and ACCOUNT_NO = '019144443904') A

Em
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-03 : 03:20:24
try this
select Max(D1) from(
select Max(DATE) as D1 From T_BANK_IMPORT_BI Where BANK_CODE = 'HSBC' and ACC_NO = '019144443904'
Union select Max(DATE) as D1 From M_SET_NO_TRANSDATE Where BANK_CODE = 'HSBC' and ACCOUNT_NO = '019144443904')t
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-03-03 : 05:31:49
thnks very much.
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-03-03 : 05:33:28
thnks very much.
Go to Top of Page

hspatil31
Posting Yak Master

182 Posts

Posted - 2009-03-03 : 05:34:56
thnks very much.
Go to Top of Page
   

- Advertisement -