SQL question

Results 1 to 3 of 3

Thread: SQL question

  1. #1
    Join Date
    Dec 1969

    Default SQL question

    Can you place a subquery containing an aggregate function inside of an aggregate function? Here is my statement that doesn&#039;t work:<BR><BR>SELECT Max(SELECT COUNT(QID) AS QuestionCount<BR> FROM Questions<BR> WHERE (ProjectID = 2784) AND (BlockID IS NOT NULL)<BR> GROUP BY BlockID) AS Result<BR>FROM Questions<BR><BR>The subquery would return:<BR><BR>QuestionCount<BR>-------------<BR>4<BR>3<BR>5<BR>2<BR>3<BR><BR>and I&#039;m trying to get the max from the result set. Is this possible? Currently I get "Incorrect Syntax near the keyword SELECT". I appreciate any help.

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default No <eop>


  3. #3
    Join Date
    Dec 1969

    Default Not directly.

    I had a problem like this - I needed the SUM of a SUBQUERY to be used in a later validation.<BR><BR>It was quite the mess.<BR><BR>But, I did find that I could do a JOIN on the SUBQUERY and then use the derived field in my SUM().

Posting Permissions

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