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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to get a Max id whole number from select

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 wholenumber

SELECT MAX(taskorderSeq) FROM tbl_myTaskorders

with 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 .12

the 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.aspx

2) you could convert the value to an integer via CONVERT or CAST.

or

3) 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).

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-05-03 : 23:07:46
SELECT CONVERT(NUMERIC(10),MAX(taskorderSeq)) FROM tbl_myTaskorders

quote:
Originally posted by cplusplus

I have the following How to get a max taskordersequence wholenumber

SELECT MAX(taskorderSeq) FROM tbl_myTaskorders

with 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 .12

the result should be just 22, can you help thank you very mucyh for the information.






hey
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-05-03 : 23:19:15
easy way is
SELECT FLOOR(MAX(taskorderSeq)) FROM tbl_myTaskorders

quote:
Originally posted by cplusplus

I have the following How to get a max taskordersequence wholenumber

SELECT MAX(taskorderSeq) FROM tbl_myTaskorders

with 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 .12

the result should be just 22, can you help thank you very mucyh for the information.






hey
Go to Top of Page
   

- Advertisement -