Hoogle Search
Within LTS Haskell 24.0 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
groupBy :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto GROUP BY clause. You can enclose multiple columns in a tuple.
select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy (bar ^. BarId, bar ^. BarName) return (bar ^. BarId, bar ^. BarName, countRows)
With groupBy you can sort by aggregate functions, like so (we used let to restrict the more general countRows to SqlSqlExpr (Value Int) to avoid ambiguity---the second use of countRows has its type restricted by the :: Int below):r <- select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy $ bar ^. BarName let countRows' = countRows orderBy [asc countRows'] return (bar ^. BarName, countRows') forM_ r $ \(Value name, Value count) -> do print name print (count :: Int)
Need more columns?
The ToSomeValues class is defined for SqlExpr and tuples of SqlExprs. We only have definitions for up to 8 elements in a tuple right now, so it's possible that you may need to have more than 8 elements. For example, consider a query with a groupBy call like this:groupBy (e0, e1, e2, e3, e4, e5, e6, e7)
This is the biggest you can get with a single tuple. However, you can easily nest the tuples to add more:groupBy ((e0, e1, e2, e3, e4, e5, e6, e7), e8, e9)
groupBy :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto.Experimental GROUP BY clause. You can enclose multiple columns in a tuple.
select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy (bar ^. BarId, bar ^. BarName) return (bar ^. BarId, bar ^. BarName, countRows)
With groupBy you can sort by aggregate functions, like so (we used let to restrict the more general countRows to SqlSqlExpr (Value Int) to avoid ambiguity---the second use of countRows has its type restricted by the :: Int below):r <- select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy $ bar ^. BarName let countRows' = countRows orderBy [asc countRows'] return (bar ^. BarName, countRows') forM_ r $ \(Value name, Value count) -> do print name print (count :: Int)
Need more columns?
The ToSomeValues class is defined for SqlExpr and tuples of SqlExprs. We only have definitions for up to 8 elements in a tuple right now, so it's possible that you may need to have more than 8 elements. For example, consider a query with a groupBy call like this:groupBy (e0, e1, e2, e3, e4, e5, e6, e7)
This is the biggest you can get with a single tuple. However, you can easily nest the tuples to add more:groupBy ((e0, e1, e2, e3, e4, e5, e6, e7), e8, e9)
groupBy :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto.Internal.Internal GROUP BY clause. You can enclose multiple columns in a tuple.
select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy (bar ^. BarId, bar ^. BarName) return (bar ^. BarId, bar ^. BarName, countRows)
With groupBy you can sort by aggregate functions, like so (we used let to restrict the more general countRows to SqlSqlExpr (Value Int) to avoid ambiguity---the second use of countRows has its type restricted by the :: Int below):r <- select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy $ bar ^. BarName let countRows' = countRows orderBy [asc countRows'] return (bar ^. BarName, countRows') forM_ r $ \(Value name, Value count) -> do print name print (count :: Int)
Need more columns?
The ToSomeValues class is defined for SqlExpr and tuples of SqlExprs. We only have definitions for up to 8 elements in a tuple right now, so it's possible that you may need to have more than 8 elements. For example, consider a query with a groupBy call like this:groupBy (e0, e1, e2, e3, e4, e5, e6, e7)
This is the biggest you can get with a single tuple. However, you can easily nest the tuples to add more:groupBy ((e0, e1, e2, e3, e4, e5, e6, e7), e8, e9)
groupBy :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto.Legacy GROUP BY clause. You can enclose multiple columns in a tuple.
select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy (bar ^. BarId, bar ^. BarName) return (bar ^. BarId, bar ^. BarName, countRows)
With groupBy you can sort by aggregate functions, like so (we used let to restrict the more general countRows to SqlSqlExpr (Value Int) to avoid ambiguity---the second use of countRows has its type restricted by the :: Int below):r <- select $ from \(foo `InnerJoin` bar) -> do on (foo ^. FooBarId ==. bar ^. BarId) groupBy $ bar ^. BarName let countRows' = countRows orderBy [asc countRows'] return (bar ^. BarName, countRows') forM_ r $ \(Value name, Value count) -> do print name print (count :: Int)
Need more columns?
The ToSomeValues class is defined for SqlExpr and tuples of SqlExprs. We only have definitions for up to 8 elements in a tuple right now, so it's possible that you may need to have more than 8 elements. For example, consider a query with a groupBy call like this:groupBy (e0, e1, e2, e3, e4, e5, e6, e7)
This is the biggest you can get with a single tuple. However, you can easily nest the tuples to add more:groupBy ((e0, e1, e2, e3, e4, e5, e6, e7), e8, e9)
GroupBy :: [SomeValue] -> GroupByClauseesqueleto Database.Esqueleto.Internal.Internal No documentation available.
groupBy_ :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto.Experimental An alias for groupBy that avoids conflict with the term from Data.List groupBy.
groupBy_ :: ToSomeValues a => a -> SqlQuery ()esqueleto Database.Esqueleto.Internal.Internal An alias for groupBy that avoids conflict with the term from Data.List groupBy.
-
esqueleto Database.Esqueleto.Internal.Internal A GROUP BY clause.
makeGroupBy :: IdentInfo -> GroupByClause -> (Builder, [PersistValue])esqueleto Database.Esqueleto.Internal.Internal No documentation available.
sdGroupByClause :: SideData -> !GroupByClauseesqueleto Database.Esqueleto.Internal.Internal No documentation available.
Page 1 of 2 | Next