Home » RDBMS Server » Server Administration » Can this be done?
Can this be done? [message #371915] Wed, 20 December 2000 10:28 Go to next message
Rob
Messages: 70
Registered: January 2000
Member
Hello,

Is this a "valid" statement?

select max(yr||mo) as LatestSubmission from TableA where fieldA = 'ABC'

....with year/month data being:
ABC yr=2000 mo=1
ABC yr=2000 mo=4
ABC yr=2000 mo=7
ABC yr=2000 mo=12

....I'm assuming this should return 200012....but it isn't, I get an "earlier" result.

Is this the right way to approach this query?

Thanks
Re: Can this be done? [message #371921 is a reply to message #371915] Thu, 21 December 2000 06:39 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
I suspect that it is returning the 2000,7 result.
If so it would be because it is doing a string comparison rather than a numeric one.

If you did max((year*100)+month) then you should get the right result
Re: Can this be done? [message #371923 is a reply to message #371915] Thu, 21 December 2000 08:40 Go to previous message
me
Messages: 66
Registered: August 2000
Member
select max( to_date(yr||mo, 'yyyymm') )
Previous Topic: I don't know a lot of things ;)
Next Topic: data encryption
Goto Forum:
  


Current Time: Thu May 16 20:55:22 CDT 2024