Reputation: 1
I'm a trying to figure out how to use a column alias in a select case when grouping. I've got my query to work. The only problem is AccountsDescription is the actual column name and I need the result set to use the alias Account instead. Can someone point me in the right direction?
Select
Case
When GROUPING (AccountDescription) = 1 then '*ALL*'
Else AccountDescription
End As AccountDescription,
Vendors.VendorState As State,
Sum(InvoiceLineItems.InvoiceLineItemAmount) as LineItemSum
From
InvoiceLineItems Join GLAccounts On
InvoiceLineItems.AccountNo = GLAccounts.AccountNo
Join Invoices On
InvoiceLineItems.InvoiceID = Invoices.InvoiceID
Join Vendors On
Invoices.VendorID = Vendors.VendorID
Group by GLAccounts.AccountDescription, Vendors.VendorState with Cube
Upvotes: 0
Views: 1240