Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MOD() function in SQL Server ?

Status
Not open for further replies.

MUJEEB

IS-IT--Management
Dec 3, 2001
2
AE

Can someone tell me the function name for MOD operation in SQL Server ?

Thankx
 
Hi There

By MOD(), I persume you mean that you want to return a remainder.

You can do this in SQL by using the % operator.

This example is from BOL .....


This example returns the book title number and any modulo (remainder) of dividing the price (converted to an integer value) of each book into the total yearly sales (ytd_sales * price).

USE pubs

GO

SELECT title_id,

CAST((ytd_sales * price) AS int) %CAST(price AS int) AS Modulo

FROM titles

WHERE price IS NOT NULL and type = 'trad_cook'

ORDER BY title_id

GO


Hope this helps. Bernadette
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top