53

Вопрос по sql – Как я могу изменить NULL на 0 при получении одного значения из функции SQL?

Error: User Rate Limit Exceeded

SELECT SUM(Price) AS TotalPrice 
FROM Inventory
WHERE (DateAdded BETWEEN @StartDate AND @EndDate)

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
8 ответов
  • 11

    Code:

    SELECT 0+COALESCE(SUM(Price),0) AS TotalPrice
    FROM Inventory
    WHERE (DateAdded BETWEEN @StartDate AND @EndDate)
    

  • 6

    Error: User Rate Limit Exceeded

    SELECT COALESCE(
        (SELECT SUM(Price) AS TotalPrice 
        FROM Inventory
        WHERE (DateAdded BETWEEN @StartDate AND @EndDate))
        , 0)
    

  • 13

    Error: User Rate Limit Exceeded

    SELECT ISNULL(SUM(Price), 0) AS TotalPrice 
    FROM Inventory
    WHERE (DateAdded BETWEEN @StartDate AND @EndDate)
    

  • 1

    Error: User Rate Limit Exceeded

    SELECT NVL(SUM(Price), 0) AS TotalPrice 
    FROM Inventory
    WHERE (DateAdded BETWEEN @StartDate AND @EndDate)
    

    This SQL statement would return 0 if the SUM(Price) returned a null value. Otherwise, it would return the SUM(Price) value.

  • 4

    Error: User Rate Limit Exceeded

    SELECT ISNULL(SUM(ISNULL(Price, 0)), 0).

  • 93

    Error: User Rate Limit Exceeded

    SELECT COALESCE(SUM(Price),0) AS TotalPrice
    FROM Inventory
    WHERE (DateAdded BETWEEN @StartDate AND @EndDate)
    

    SELECT coalesce(SUM(column_id),0) AS TotalPrice 
    FROM sys.columns
    WHERE (object_id BETWEEN -1 AND -2)
    

  • -5

    Error: User Rate Limit Exceeded

    $A=($row['SUM'Price']+0);
    echo $A;
    

  • 6

    Edit:Error: User Rate Limit Exceeded

    Error: User Rate Limit Exceeded

    ISNULL()Error: User Rate Limit Exceeded

    Error: User Rate Limit Exceeded

    SELECT ISNULL(SUM(Price), 0) AS TotalPrice 
    FROM Inventory
    WHERE (DateAdded 
    BETWEEN @StartDate AND @EndDate)