Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2007-05-03 : 22:59:40
|
| I have the following How to get a max taskordersequence wholenumberSELECT MAX(taskorderSeq) FROM tbl_myTaskorderswith the above query it is also getting the result as 22.12, instead i want to check and get by whole number only not looking at the decimal values in the above case .12the result should be just 22, can you help thank you very mucyh for the information. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-05-03 : 23:05:21
|
| You have 3 good options:1) SQL has a ROUND function you can use: http://msdn2.microsoft.com/en-us/library/ms175003.aspx2) you could convert the value to an integer via CONVERT or CAST.or3) If it is just for display purposes, you can leave the value as is and simply output it with no decimal places at your presentation layer (i.e., report, web page, client application -- whatever it is that is calling your sql and using the results).- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
hey001us
Posting Yak Master
185 Posts |
Posted - 2007-05-03 : 23:07:46
|
SELECT CONVERT(NUMERIC(10),MAX(taskorderSeq)) FROM tbl_myTaskordersquote: Originally posted by cplusplus I have the following How to get a max taskordersequence wholenumberSELECT MAX(taskorderSeq) FROM tbl_myTaskorderswith the above query it is also getting the result as 22.12, instead i want to check and get by whole number only not looking at the decimal values in the above case .12the result should be just 22, can you help thank you very mucyh for the information.
hey |
 |
|
|
hey001us
Posting Yak Master
185 Posts |
Posted - 2007-05-03 : 23:19:15
|
easy way is SELECT FLOOR(MAX(taskorderSeq)) FROM tbl_myTaskordersquote: Originally posted by cplusplus I have the following How to get a max taskordersequence wholenumberSELECT MAX(taskorderSeq) FROM tbl_myTaskorderswith the above query it is also getting the result as 22.12, instead i want to check and get by whole number only not looking at the decimal values in the above case .12the result should be just 22, can you help thank you very mucyh for the information.
hey |
 |
|
|
|
|
|