我想在 Scala 中进行总结。
我有一个案例类实例列表。
case class Structure(structureFirst:String,structureSecond:String,structureThird:String,count:Int)
val structures = List(
Structure("first001","second001","third001",1),
Structure("first002","second002","third002",2),
Structure("first002","second002","third002",2),
Structure("first003","second003","third003",3),
Structure("first003","second003","third003",3),
Structure("first003","second003","third003",3),
Structure("first004","second004","third004",4),
Structure("first004","second004","third004",4),
Structure("first004","second004","third004",4),
Structure("first004","second004","third004",4)
)
那么我想总结一下这样的SQL。
SELECT SUM(Structure.count) FROM structures GROUP BY Structure.structureFirst,Structure.structureSecond,Structure.structureThird;
这是输出。
val result = List(
Structure("first001","second001","third001",1),
Structure("first002","second002","third002",4),
Structure("first003","second003","third003",9),
Structure("first004","second004","third004",16)
)
我该如何总结这一点?
谢谢。