|
The following
script illustrates the calculation of percent of orders by country on base of all orders. The CONVERTs functions are used to format the percentage figures in currency format.
use Northwind;
go
select
Country,
Percentage =
convert(varchar,convert(money,100.0 * count(*)/
(select count(*) from Orders)),1)+'%'
from Customers c
join Orders o
on c.CustomerID = o.CustomerID
group by Country
order by count(*) desc
go
|