FEflag = AssociationThread[{"userId", "A1flag"}, #] & /@
{{5311, 1}, {5311, 1}, {5313, 1}, {5313, 1}, {5313, 1}, {5313, 0}} // Dataset

GroupBy[FEflag, First -> Last, Total]

The same result can be achieved more robustly with
GroupBy[FEflag, Key["userId"] -> Key["A1flag"], Total]

which makes fewer assumptions about the ordering of the columns.
I don't know a pretty way of keeping the name of the first column, but the following works by reconstructing a new Dataset from the results of GroupBy:
KeyValueMap[<|"userId" -> #1, "sum" -> #2|> &,
GroupBy[FEflag, Key["userId"] -> Key["A1flag"], Total]]

edit
Following @VictorK. 's solution, the above query can be simplified a bit:
KeyValueMap[<|"userId" -> #1, "sum" -> #2|> &,
FEflag[GroupBy["userId"], Total, "A1flag"]]

FEflag = AssociationThread[{"userId", "A1flag"}, #] & /@ {{5311, 1}, {5311, 1}, {5313, 1}, {5313, 1}, {5313, 1}} // Dataset– Carl Lange Apr 04 '19 at 17:28Values@GroupBy[FEflag[Select[#A1flag == 1 &], All], "userId", Total]should do it, but it will only work when the value ofA1flagis 1, or it will count weird. – Carl Lange Apr 04 '19 at 17:31