I have a scenario where in I want to have a result that counts each price and the related number of billables and then add all those up and give me a total.
Basically I have this code that gives me the price and the number of billables for each price.
select price, count(price)
and time > Convert(Datetime, Convert(varchar, GetDate()-1, 101))
and time < Convert(Datetime, Convert(varchar, GetDate(), 101))
group by price
Now I get the result like below:
Now, I want to take this and give a result so that I get a total like below:
$0.30 * 31 + $0.75 * 126 + $0.99 * 44
How can I do this, and can I do all this in one Select, if not, it is ok.. please let me know ...however possible.