Select Max Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a table with

control_no
--------------------
PR1520
PR2

When i do the max on the control_no column i get

------------------------------
PRU2

but it is wrong as it should be 'PR1520' any idea on query

Thanks
Prasad
 
Prasad Patil said:
Hi

I have a table with

control_no
--------------------
PR1520
PR2

When i do the max on the control_no column i get

------------------------------
PRU2

but it is wrong as it should be 'PR1520' any idea on query

Thanks
Prasad
What data type, String?
It's normal collating sequence. If you want PR1520 to be > PR2, enter PR2 as
PR0002.
 
Prasad Patil said:
Its a string data

select max(intnos) from #nos

returns it wrong

Regards,
Prasad
In your first post, you referred to " the control_no column ". Now you are
referring to intnos and #nos?

My comment regarding your previously cited string data applies. What is
intnos and #nos?
 
Prasad said:
Its a string data

select max(intnos) from #nos

returns it wrong

Regards,
Prasad

You're expecting string data to behave like integer data. That just
doesn't fly. Think about what you get when you sort it alphabetically
and getting the top or bottom row (depending on your sort order). i.e.
select intnos from #nos order by intnos desc

What is the value of your 1st row.. that will be the value returned by
max(intnos)
 
Back
Top