Tuesday, January 3, 2012

compute by in sql server

Drawback of group by is we can display information from only those columns that are used in group by and not possible to display the information from other columns available in the table that are not used in group by.When you want to display information from the columns in the table that are not used for grouping while grouping the rows,use "compute by"
syntax:
select statement computeby
ex:Display complete details of orders along with total quantity transfer to customers
select*from orders compute sum(quantity)
Display complete details of orders along with total quantity transfer to customers
select*from orders orederby customerno  compute sum(quantity) by customerno
Rule:A rule to use compute by is the columns that are specified in compute by must be in order by
Post a Comment

Bel