sub total query

Dalam SQL Server terdapat fungsi yang memmungkinkan kita untuk melakukan sub total dalam satu query secara langsung.


SELECT ISNULL(strCustomerID,'GRAND TOTAL') AS [Customer ID], ISNULL(strID, 'TOTAL') AS TransID, SUM(monTotalAmountSalesOrder) AS Amount
FROM ONE_AR_SalesOrder
GROUP BY strCustomerID, strID WITH ROLLUP

dengan kode diatas akan di hasilkan result sbb :

SubTotalQuery

Sumber :
SQL Server BOL

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.