Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can T-SQl do this?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

p2bl
Yak Posting Veteran

China
54 Posts

Posted - 11/30/2001 :  08:05:38  Show Profile  Visit p2bl's Homepage  Send p2bl an ICQ Message  Reply with Quote
Here is a table "table1" with a char(5) column "col1"
the value in col1 looks like this:
12345
23568
01235

the value of col consists of number
if I wanner get a char(5) result that every digit of this value
should be the max of the value of col at the same digit,how to?
I have thought this for about a week?Maybe it is a mission impossible?


I do not know what is what

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 11/30/2001 :  08:17:28  Show Profile  Reply with Quote
Like this?

SELECT MAX(SUBSTRING(col1, 1, 1))
+ MAX(SUBSTRING(col1, 2, 1))
+ MAX(SUBSTRING(col1, 3, 1))
+ MAX(SUBSTRING(col1, 4, 1))
+ MAX(SUBSTRING(col1, 5, 1))
FROM table1



Go to Top of Page

izaltsman
A custom title

USA
1139 Posts

Posted - 11/30/2001 :  08:30:01  Show Profile  Send izaltsman an AOL message  Send izaltsman an ICQ Message  Reply with Quote
If you have values that are less then 5 characters long and you want to treat them as right-aligned, replace col1 in Arnold's statement with

(REPLICATE(' ', 5-LEN(col1))+col1)

to pad the value with spaces.

Go to Top of Page

p2bl
Yak Posting Veteran

China
54 Posts

Posted - 11/30/2001 :  08:33:40  Show Profile  Visit p2bl's Homepage  Send p2bl an ICQ Message  Reply with Quote
Ha ha.So simple!
I find myself a idiot!
Thanks a lot

I do not know what is what
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000