Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Error on using count aggregate function inside sum

$
0
0

I have the following query :

select
        a.username, count(a.problemID) as NumberOfSubmission,
        Q_Score = sum(
        case
            when a.accepted = 0  then -2
            when count(a.accepted) > 1 then -1
          else 20
        end)
    from tblSubmission a

I am getting the following error :

"Cannot perform an aggregate function on an expression containing an aggregate or a subquery."

Can anyone tell me how can I use the count aggregation function or something similar to count here?

Thank You



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>