SELECT type, SUM(price), SUM(advance)FROM titlesWHERE type LIKE '%cook'GROUP BY typeORDER BY type

解决方案 »

  1.   

    SUM (T-SQL)
    Returns the sum of all the values, or only the DISTINCT values, in the expression. SUM can be used with numeric columns only. Null values are ignored.Syntax
    SUM([ALL | DISTINCT] expression)Arguments
    ALL 
    Applies the aggregate function to all values. ALL is the default. 
    DISTINCT 
    Specifies that SUM return the sum of unique values. 
    expression 
    Is a constant, column, or function, and any combination of arithmetic, bitwise, and string operators. expression is an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted. 
    Return Types
    Returns the summation of all expression values in the most precise expression data type.Expression result Return type 
    integer category int 
    decimal category (p, s) decimal(38, s) 
    money and smallmoney category money 
    float and real category float