Reference > Functions > Mathematical
Floor
- 2005
- 2008
- 2012
- 2014
- 2016
- 2017
- 2019
- 2022
- 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022
Floor Mathematical Function
Use the Floor
function to returns the largest integer value less than or equal to the specified expression.
Syntax
db.fx.Floor({expression})
Arguments
- expression
- – The value to use in the floor calculation.
Returns
Examples
Select Statement
Select the floor of total purchase amount for all purchases.
IEnumerable<double> value = db.SelectMany(
db.fx.Floor(dbo.Purchase.TotalPurchaseAmount)
)
.From(dbo.Purchase)
.Execute();
Where Clause
Select all purchase ids where the floor of total purchase amount is less than or equal to 100.
IEnumerable<int> value = db.SelectMany(
dbo.Purchase.Id
)
.From(dbo.Purchase)
.Where(db.fx.Floor(dbo.Purchase.TotalPurchaseAmount) <= 100)
.Execute();
Order By Clause
Select the floor value of total purchase amount for all purchases ordered by the floor value descending.
IEnumerable<double> value = db.SelectMany(
dbo.Purchase.TotalPurchaseAmount
)
.From(dbo.Purchase)
.OrderBy(db.fx.Floor(dbo.Purchase.TotalPurchaseAmount).Desc())
.Execute();
Group By Clause
Select the payment method and floor of total purchase amount for all purchases, grouped by payment method type and ordered by the floor of total purchase amount.
IEnumerable<dynamic> values = db.SelectMany(
dbo.Purchase.PaymentMethodType,
db.fx.Floor(dbo.Purchase.TotalPurchaseAmount).As("TotalPurchaseAmount")
)
.From(dbo.Purchase)
.GroupBy(
dbo.Purchase.PaymentMethodType,
db.fx.Floor(dbo.Purchase.TotalPurchaseAmount)
)
.OrderBy(db.fx.Floor(dbo.Purchase.TotalPurchaseAmount))
.Execute();
Having Clause
Select the payment method and absolute value of total purchase amount for all purchases, grouped by payment method type having an absolute value greater than 10 and ordered by the absolute value of total purchase amount.
IEnumerable<dynamic> values = db.SelectMany(
dbo.Purchase.PaymentMethodType,
db.fx.Floor(dbo.Purchase.TotalPurchaseAmount).As("TotalPurchaseAmount")
)
.From(dbo.Purchase)
.GroupBy(
dbo.Purchase.PaymentMethodType,
db.fx.Floor(dbo.Purchase.TotalPurchaseAmount)
)
.Having(db.fx.Floor(dbo.Purchase.TotalPurchaseAmount) > 10)
.OrderBy(db.fx.Floor(dbo.Purchase.TotalPurchaseAmount))
.Execute();