Q:

sql: have an aggregate repeat over the excess rows of a returned result so I can do calculations with it in each row

What I want to do is I have one column grouped up, I want to compare it to a column that's similar but aggregate so only one row in that column.   I want to compare the aggregate row to every row in the grouping.   My thinking is something like this but maybe there's a better way? 
select CustomerID, count(OrderID), count(OrderID)/TotalOrders from Order_T 
full outer join (select count(OrderID) TotalOrders from Order_T)
group by CustomerID;

I'm sure this won't run the way it is but I just want to show my train of thought.   I want the number of orders of a particular customer divided by the total number of orders in the table.   The percentage the customer represents in orders.   Can this be done in one statement?   Probably in a totally different way than I'm thinking. 

A:

One way to do this is to simply introduce the total count as a subquery in the select statement.  This is written using T-SQL syntax for SQL Server, but except for the cast it should be generic SQL. 
select 
    CustomerID, 
    count(OrderID), 
    count(OrderID) / cast( (select count(OrderID) TotalOrders 
                            from Order_T) as decimal(10,3)
                         ) 
from Order_T 
group by CustomerID

I added the cast to decimal in case the counts are integers so that fractions won't be lost.  The odd formatting was just for readability.