Re: I upsized but these SQL statements are causing errors...

From: Steven Scaife (sp_at_nospam.com)
Date: 09/09/04


Date: Thu, 9 Sep 2004 17:49:23 +0100

I'm not too sure but according to books online they are usable here is what
books online says

SUM
Returns the sum of all the values, or only the DISTINCT values, in the
expression. SUM can be used with numeric columns only. Null values are
ignored.

Syntax
SUM ( [ ALL | DISTINCT ] expression )

Arguments
ALL

Applies the aggregate function to all values. ALL is the default.

DISTINCT

Specifies that SUM return the sum of unique values.

expression

Is a constant, column, or function, and any combination of arithmetic,
bitwise, and string operators. expression is an expression of the exact
numeric or approximate numeric data type category, except for the bit data
type. Aggregate functions and subqueries are not permitted.

and for iif

IIf
Returns one of two numeric or string values determined by a logical test.

Syntax
Numeric
IIf(«Logical Expression», «Numeric Expression1», «Numeric Expression2»)

This function returns «Numeric Expression1» if «Logical Expression»
evaluates to TRUE, otherwise returns «Numeric Expression2».

String
IIf(«Logical Expression», «String Expression1», «String Expression2»)

This function returns «String Expression1» if «Logical Expression» evaluates
to TRUE, otherwise returns «String Expression2».

check books online for more about these just thought these descriptions
might help, someone will be able to tell you better if this is no good to
you

"Mike" <mike_newsgroups@yahoo.com> wrote in message
news:6a68ace3.0409090831.6735eaea@posting.google.com...
> OK after all the "get rid of Access" stuff I finally starting upsizing
> to sql server. However, some of the sql is breaking now. It seems to
> be my use of stuff like
>
> sum(trade)
> sum(iif(want>0,1,0))
>
> what is the sql server equivalent sql of sum and iif?
>
> Thanks,
> Mike



Relevant Pages

  • Re: [SQL query] Generate a report from events?
    ... sum of device #1 between midnight and 10:00: ... DECLARE @endtime datetime; ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Grouping Dates
    ... AVGAS avgtrayweight ... sum these by the datemy ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Need help with SQL satement - newbie
    ... than one record for a given 'siteID' then it needs to total (sum) most ... Judging from the syntax, you are not using SQL Server (which is what ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Tough Sql Query
    ... wanted SUMbut the desired output you posted earlier ... That sum is hopefully always 0, or else something is really broken! ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Sum Accumulating Data
    ... I need to SUM the data up the point where the data gets reset (the next ... INSERT statements with sample data. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)

Quantcast