You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Database.HaskellDB
import Database.HaskellDB.PrimQuery
import Database.HaskellDB.Query
import Database.HaskellDB.DBLayout
data Name' = Name'
instance FieldTag Name' where
fieldName _ = "name"
data Apples = Apples
instance FieldTag Apples where
fieldName _ = "age"
name :: Attr Name' String
name = mkAttr Name'
apples :: Attr Apples Int
apples = mkAttr Apples
applesTable :: Table (RecCons Name' (Expr String) (RecCons Apples (Expr Int) RecNil))
applesTable = Table "apples" [ ("name", AttrExpr "namecol")
, ("apples", AttrExpr "applecol")]
totalApples :: Query (Rel (RecCons Name' (Expr String) (RecCons Apples (Expr Int) RecNil)))
totalApples = do
t <- table applesTable `union` table applesTable
project (name << t!name #
apples << _sum(t!apples))
The aggregation is done before the union. It should be after.
*Main> putStrLn $ showSql totalApples
(SELECT namecol as name,
SUM(age3) as age
FROM apples as T1
GROUP BY namecol)
UNION
(SELECT namecol as name,
SUM(age3) as age
FROM apples as T1
GROUP BY namecol)
The text was updated successfully, but these errors were encountered:
The aggregation is done before the union. It should be after.
The text was updated successfully, but these errors were encountered: