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
 General SQL Server Forums
 New to SQL Server Programming
 Counting

Author  Topic 

Prabhat33
Starting Member

4 Posts

Posted - 2012-09-19 : 03:37:56
Hi again,
i want to group the numbers by dividing it by 60 like this:
6/60 should be 1
61/60 should be 2
121/60 should be 3.

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-09-19 : 03:46:34
add 60 to it and then divide.

assuming that your column is integer

SELECT (60 + yourcol) / 60



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

joshua_caleb
Starting Member

3 Posts

Posted - 2012-09-19 : 04:17:46
If your data type is a decimal or float, you could use the Ceiling function

SELECT Val1, CEILING(Val1 / 60)

Josh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-19 : 11:52:24
quote:
Originally posted by khtan

add 60 to it and then divide.

assuming that your column is integer

SELECT (60 + yourcol) / 60



KH
[spoiler]Time is always against us[/spoiler]




wont this return 2 for 60 as well?
i guess what OP is after is till 60 result should be 1 and from 61 it should be 2 etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-19 : 11:53:23


SELECT ((yourcol-1)/60)+1 FROM table


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -