Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    20

    Unanswered: use of subqueries in an aggregate function

    hi there,
    I have a query that works on sybase and want to make it also works on SQL Server.
    The problem is that in this query I 'm using a subquery in an aggregate function.
    It seems that SQL Server unlike Sybase doesn't support the use of subquery in aggregate function.
    How can I overcome this problem.

    Thanks,
    Fady

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    YOu can start by showing us the query...

    And I've seen sybase do stuff that should blow up

    SELECT Col1, Col2, SUM(Col3)
    FROM myTable99

    AND THE DAMN THING RUNS!

    Go figure....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2003
    Posts
    20
    for example

    select col1,
    col2,
    sum(select col1 from table2 where ...)
    from table1
    where ....

    The problem is the use of select col1 from table2... inside sum.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select col1,
    col2,
    (select sum(col1) from table2 where ...) as sum41
    from table1
    where ....
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •