SQL Server Performance Forum – Threads Archive
need max date value
Hi! I have a program I’m writing in PROIV where I’m accessing an oracle table. It’s been a while since I’ve used SQL so I need some guidance please. <br /><br />Here’s what I have…<br /><br />SELECT MAX(BIL_AUDIT_DATE) INTO :$LAST_CHANGE FROM BIL_BILLING_AUDIT_TBL WHERE<br />BIL_POLICY_NUM = <img src=’/community/emoticons/emotion-4.gif’ alt=’![Stick Out Tongue :p :p](styles/default/xenforo/smilies/tongue.png)
![Smile :) :)](styles/default/xenforo/smilies/smile.png)
subquery that selects the max (date) select * from mytable where a=z and b=y and date = (select max(date) from mytable where a=z and b=y) http://www.tradeco.co.uk
I’m not familiar with Oracle’s syntax, but that looks like you want to assign the MAX(date) to a variable. If that’s correct, you might want to use something like this:<br /><pre id="code"><font face="courier" size="2" id="code"><br />DECLARE @dt DATETIME<br />SELECT @dt = MAX(BIL_AUDIT_DATE) <br /> FROM BIL_BILLING_AUDIT_TBL <br /> WHERE BIL_POLICY_NUM = <img src=’/community/emoticons/emotion-4.gif’ alt=’
![Stick Out Tongue :p :p](styles/default/xenforo/smilies/tongue.png)
]]>