Click here to Skip to main content
15,891,943 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dispalying data in word document Pin
Simon P Stevens16-Nov-08 23:35
Simon P Stevens16-Nov-08 23:35 
GeneralRe: Dispalying data in word document Pin
sram1517-Nov-08 19:37
sram1517-Nov-08 19:37 
GeneralRe: Dispalying data in word document Pin
Simon P Stevens17-Nov-08 21:42
Simon P Stevens17-Nov-08 21:42 
GeneralRe: Dispalying data in word document Pin
sivaddrahcir11-Feb-09 8:43
sivaddrahcir11-Feb-09 8:43 
QuestionMax Value Pin
Zeyad Jalil16-Nov-08 22:34
professionalZeyad Jalil16-Nov-08 22:34 
AnswerRe: Max Value Pin
Simon P Stevens16-Nov-08 22:51
Simon P Stevens16-Nov-08 22:51 
GeneralRe: Max Value Pin
Zeyad Jalil16-Nov-08 22:56
professionalZeyad Jalil16-Nov-08 22:56 
GeneralRe: Max Value Pin
Simon P Stevens16-Nov-08 23:22
Simon P Stevens16-Nov-08 23:22 
Ahh. Well that's because as a string "9/50" comes after "10/50" because when you interpret it as a string, "9" is higher than "1".

I don't think there is an easy way of doing this in SQL.

Personally, I think your data type is wrong. If it's a numeric value you should be using some form of numeric data type, not a string.

If you can't change the data type, then it could be rather tricky. You would have to write a function that first split the string at the '/' sign and extracted the first half (This could be done with CHARINDEX[^] and SUBSTRING[^]. Possibly something like this: SUBSTRING(ColumnName, 0, CHARINDEX('/', ColumnName)), then converted the string to a number (Possibly using CAST or CONVERT[^]). Then you could return the MAX value of this function.
SELECT     MAX(CAST(SUBSTRING(ColumnName, 0, CHARINDEX('/', ColumnName)) AS Integer)) AS ExpressionName
FROM         TableName


It's not quick though. I tested it on a table with only 10 rows in it, and it's quite slow. If you've got any significant amount of data to process it will take a long time.

Consider adding an extra Integer column to the table to store just the numeric component. This can then be pre set when the row is created or changed, so when you need to read the data you don't have to calculate it every time.

Simon

GeneralRe: Max Value Pin
HosamAly17-Nov-08 2:56
HosamAly17-Nov-08 2:56 
QuestionLast row insrted into database? Pin
Zeyad Jalil16-Nov-08 22:13
professionalZeyad Jalil16-Nov-08 22:13 
AnswerRe: Last row insrted into database? Pin
Simon P Stevens16-Nov-08 23:02
Simon P Stevens16-Nov-08 23:02 
AnswerRe: Last row insrted into database? Pin
Samer Aburabie17-Nov-08 11:13
Samer Aburabie17-Nov-08 11:13 
QuestionDataGridView.... Pin
zeeShan anSari16-Nov-08 21:38
zeeShan anSari16-Nov-08 21:38 
AnswerRe: DataGridView.... Pin
Pedram Behroozi16-Nov-08 21:48
Pedram Behroozi16-Nov-08 21:48 
Questionthe scrollbar in listview Pin
Seraph_summer16-Nov-08 20:34
Seraph_summer16-Nov-08 20:34 
AnswerRe: the scrollbar in listview Pin
Simon P Stevens17-Nov-08 0:09
Simon P Stevens17-Nov-08 0:09 
Questioni need inject a plug to a project Pin
chenli051316-Nov-08 20:29
chenli051316-Nov-08 20:29 
QuestionExcel file format saving as XMLSpreadsheet [modified] Pin
Sridaran Sriram16-Nov-08 19:54
Sridaran Sriram16-Nov-08 19:54 
AnswerRe: Excel file format saving as XMLSpreadsheet Pin
Wolfram Steinke20-Oct-09 18:58
Wolfram Steinke20-Oct-09 18:58 
GeneralRe: Excel file format saving as XMLSpreadsheet Pin
Sridaran Sriram21-Oct-09 7:17
Sridaran Sriram21-Oct-09 7:17 
Questionreg clr type.. Pin
madeline_veda16-Nov-08 19:42
madeline_veda16-Nov-08 19:42 
AnswerRe: reg clr type.. Pin
Guffa16-Nov-08 21:15
Guffa16-Nov-08 21:15 
QuestionHow and Where to store passwords,Credit card number,Username etc on my computer? Pin
Sandeep Kalra16-Nov-08 19:24
Sandeep Kalra16-Nov-08 19:24 
AnswerRe: How and Where to store passwords,Credit card number,Username etc on my computer? Pin
Muhammad Shahid Farooq16-Nov-08 19:31
professionalMuhammad Shahid Farooq16-Nov-08 19:31 
AnswerRe: How and Where to store passwords,Credit card number,Username etc on my computer? Pin
Shyam Bharath16-Nov-08 19:33
Shyam Bharath16-Nov-08 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.