sql server 2008 r2 - SQL sub total and final total query -


I need to expand my SQL query which currently provides sub totals with this query, sub-sum and gorgeous There is no way to return both:

  SELECT oi.PurchaseID, SUM (O. Queti * Convert (decimal (18,2), p. AMPRICIS) VPPCCT  

Can I make another? Nickname for grand total? I have tried a few different ways and till now I am subtracting sub-tattles in a floating table towards INSERT and returning the value in a stored proc.

Any advice is highly appreciated!

You do not specify the database you are using, but with many databases rollups Clause support for group :

  SELECT oi.PurchaseID, SUM (o.Quanity * CONVERT (decimal (18,2), p. ItemPrice)) as sub_total FROM VwPurchaseType PL on OIP PL. PA CallerID = OI. Cholerid where oi UserID = 1 Group by OI. Rollup with purchase;  

This will add an additional line where PurchaseId is NULL . There is totality in it.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -