About 6,650 results
Open links in new tab
  1. Mathematical Function within Sql Case Statement

    May 4, 2016 · The steps I have taken is using the Case Statement. Here is my snippet of the select statement that I am using currently: DECLARE @Mileage NVARCHAR(75) = NULL, @IsMiles BIT = 1, @Converted NVARCHAR(75) = NULL SELECT [Id],Odometer,IsMiles, CASE IsMiles when 0 THEN OdometerValue * 0.62137 else Odometer end …

  2. How to use math expression in the result of a case expression

    Apr 10, 2019 · I wanted to use a math expression in result of the case statement. For Eg, select T1.C1, T1.C2, T1.C3, case when T1.C1 = T1.C2 <or any condition for that sake> then (T1.C3 + 1) --> I wan...

  3. sql - CASE expression multiplication - Stack Overflow

    In this scenario, your CASE expression ought to be: WHEN curOther > .04 . THEN (curOther * .01) + curOther . ELSE (curOther * .25) + curOther . END. Which could be further simplified to: WHEN curOther > .04 . THEN curOther * 1.01 . ELSE curOther * 1.25. END. You actually want the CASE expression to return:

  4. SQL CASE Statement in WHERE Clause Examples

    Dec 18, 2024 · This SQL tutorial will guide you on conditionally filtering using the WHERE clause using a SQL CASE statement. The SQL CASE statement specifies a conditional expression to perform different actions depending on the input expression value. The syntax for the CASE statement in a SQL database is: WHEN value1 THEN result1. WHEN value2 THEN result2. ...

  5. How to Use the CASE Statement in SQL (With Examples)

    Mar 26, 2025 · Syntax of the CASE statement. The CASE statement in SQL follows a straightforward structure that resembles conditional statements in programming languages.. It can be implemented in two ways, depending on how conditions are evaluated: Simple CASE. The simple CASE syntax compares an expression to a set of simple expressions sequentially and returns the result of the first match.

  6. SQL CASE Expression - W3Schools

    The CASE expression goes through conditions and returns a value when the first condition is met (like an if-then-else statement). So, once a condition is true, it will stop reading and return the result.

  7. SQL CASE Examples with Multiple Conditions - Database.Guide

    Aug 20, 2024 · In this article, we’ll explore how to use the CASE statement with multiple conditions, providing simple examples that should work across most major relational database management systems (RDBMS s).

  8. How To Use Mathematical Expressions and Aggregate Functions in SQL

    Jan 29, 2022 · In this tutorial, you’ll practice using mathematical expressions. First, you’ll use numeric operations on a calculator, then use those operators on sample data to perform queries with aggregate functions, and finish with a business scenario to query sample data for more complex information and analysis. To complete this tutorial, you will need:

  9. How to use a case statement in scalar valued function in SQL?

    There are two types of CASE expression: simple and searched. You must choose one or the other - you can't use a mixture both types in one expression. Try this: WHEN @Period = 1 THEN 1. WHEN @Period > 1 AND @Period <= 7 THEN 2. WHEN @Period > 7 AND @Period <= 30 then 3. -- etc... ELSE 0.

  10. SQL Server CASE statement - SQL Server Tutorial

    The CASE expression in SQL server allows us to apply if-then-else logic in a SQL statement. A CASE consists of a number of conditions with an accompanying custom result value in a case body followed by an optional ELSE clause.

  11. Some results have been removed
Refresh