[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

The SUM function requires 1 arguments.

Posted on 2005-04-11
5
Medium Priority
?
3,581 Views
Last Modified: 2008-03-10
This works fine, but the resulting value is w/out commas to the left of the decimal:  315683437.1000

SELECT SUM(LastFillQuantity*CAST(LastFillPrice AS Money)) AS 'Total $ - '
FROM trading.dbo.trade
where timeofexecution  >= left(getdate()-0, 11)
and destination = 'aaaa'

I usually do a conversion w/MONEY in order to get the commas in place -- like this query gives me this:
Stocks Volume -   232,096,074
Total # Trades - 743,924      

SELECT 'Stocks Volume -   '+LTRIM(LEFT(CONVERT(char(16),CAST(SUM(LastFillQuantity) AS MONEY),1),13)),
+'Total # Trades - '+LTRIM(LEFT(CONVERT(char(16),CAST(count(*) AS MONEY),1),13))

but when i try that here, i get this:  
Server: Msg 174, Level 15, State 1, Line 1
The SUM function requires 1 arguments.

SELECT CONVERT(varchar(15),CAST(SUM(LastFillQuantity*CAST(LastFillPrice AS Money),1) AS 'Total $ - '
FROM trading.dbo.trade
where timeofexecution  >= left(getdate()-0, 11)
and destination = 'aaaa'

any help?
0
Comment
Question by:RLLewis
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 13758478
Maybe this

SELECT CONVERT(varchar(15),SUM(LastFillQuantity*CAST(LastFillPrice AS Money))) AS 'Total $ - '
FROM trading.dbo.trade
where timeofexecution  >= left(getdate()-0, 11)
and destination = 'aaaa'

0
 
LVL 1

Author Comment

by:RLLewis
ID: 13758493
no, that gives me this value:  315683437.10

i've always gotten my commas in place w/my money conversion.  it's just not happening this time, though
0
 
LVL 17

Accepted Solution

by:
mokule earned 1200 total points
ID: 13758511
I've got it

SELECT CONVERT(varchar(15),SUM(LastFillQuantity*CAST(LastFillPrice AS Money)),1) AS 'Total $ - '
FROM trading.dbo.trade
where timeofexecution  >= left(getdate()-0, 11)
and destination = 'aaaa'
0
 
LVL 1

Author Comment

by:RLLewis
ID: 13758529
Beauty!  I've been bothering over these two items for much of the afternoon.  Sometimes it's these little ones that will get ya.  I can't thank you enough.
0
 
LVL 17

Expert Comment

by:mokule
ID: 13758538
Glad to help You
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question