Combined query - simple question?

  • SET @AvgRating =

    (SELECT AVG(Rating)

    FROM Comments

    WHERE Comments.VidID = 1)

    SET @NumRatings =

    (SELECT COUNT(*)

    FROM Comments

    WHERE Comments.VidID = 1)

    => Can I combine these two statements somehow so I can fill both variables with one SQL statement?

    Thanks!

    Matt

  • SELECT

    @AvgRating = AVG(Rating)

    ,@NumRatings = COUNT(*)

    FROM Comments

    WHERE Comments.VidID = 1

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply