Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Collapse Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Compute

 
      
Orders
ID Item Qty Price Year
1 TV 2 10 2011
2 PC 3 20 2011
3 TV 6 50 2012
4 PC 8 60 2012
      SELECT    ID, Item, Qty, Price
      FROM      Orders
      ORDER BY  Year
      COMPUTE   SUM(Qty), SUM(Price)
    
      
Output
Total Qty Total Price
19 140