1module Rel8.Query.Distinct
12import qualified Opaleye.Distinct as Opaleye
13import qualified Opaleye.Order as Opaleye
16import Rel8.Order ( Order( Order ) )
17import Rel8.Query ( Query )
18import Rel8.Query.Opaleye ( mapOpaleye )
19import Rel8.Table.Eq ( EqTable )
20import Rel8.Table.Opaleye ( distinctspec, unpackspec )
23-- | Select all distinct rows from a query, removing duplicates. @distinct q@
24-- is equivalent to the SQL statement @SELECT DISTINCT q@.
25distinct :: EqTable a => Query a -> Query a
26distinct = mapOpaleye (Opaleye.distinctExplicit distinctspec)
29-- | Select all distinct rows from a query, where rows are equivalent according
30-- to a projection. If multiple rows have the same projection, it is
31-- unspecified which row will be returned. If this matters, use 'distinctOnBy'.
32distinctOn :: EqTable b => (a -> b) -> Query a -> Query a
33distinctOn proj = mapOpaleye (Opaleye.distinctOnExplicit unpackspec proj)
36-- | Select all distinct rows from a query, where rows are equivalent according
37-- to a projection. If there are multiple rows with the same projection, the
38-- first row according to the specified 'Order' will be returned.
39distinctOnBy :: EqTable b => (a -> b) -> Order a -> Query a -> Query a
40distinctOnBy proj (Order order) = mapOpaleye (Opaleye.distinctOnByExplicit unpackspec proj order)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list