Reference > Functions > Mathematical

Cot

  • 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022

Cot (Cotangent) Mathematical Function

Use the Cot function to return the cotangent of the specified expression.

Syntax

db.fx.Cot({expression})

Arguments

expression
The value to use in the cotangent calculation.

Returns

float

Examples

Select Statement

Select the cotangent of a product's weight (which is nullable in the database).

float? result = db.SelectOne(
        db.fx.Cot(dbo.Product.Weight)
    )
    .From(dbo.Product)
    .Execute();

Where Clause

Select the cotangent of a product's depth (which is nullable in the database).

float? result = db.SelectOne(
        db.fx.Cot(dbo.Product.Depth)
    )
    .From(dbo.Product)
    .Execute();

Order By Clause

Select and order by the cotangent of a product's depth.

IEnumerable<Product> result = db.SelectMany<Product>()
    .From(dbo.Product)
    .OrderBy(db.fx.Cot(dbo.Product.Depth).Desc())
    .Execute();

Group By Clause

Select product details grouped by product category and the cotangent of the product's depth.

IEnumerable<dynamic> results = db.SelectMany(
        dbo.Product.ProductCategoryType,
        db.fx.Cot(dbo.Product.Depth).As("calculated_value")
    )
    .From(dbo.Product)
    .GroupBy(
        dbo.Product.ProductCategoryType,
        db.fx.Cot(dbo.Product.Depth)
    )
    .Execute();

Having Clause

Select the ids of all products, grouped by product category type having a cotangent of the product's height greater than the product's width.

IEnumerable<ProductCategoryType?> results = db.SelectMany(
        dbo.Product.ProductCategoryType
    )
    .From(dbo.Product)
    .GroupBy(
        dbo.Product.ProductCategoryType,
        db.fx.Cot(dbo.Product.Height),
        dbo.Product.Width
    )
    .Having(
        db.fx.Cot(dbo.Product.Height) > dbo.Product.Width
    )
    .Execute();
Previous
Cos

© 2024 dbExpression. All rights reserved.