diff --git a/esqueleto.cabal b/esqueleto.cabal
--- a/esqueleto.cabal
+++ b/esqueleto.cabal
@@ -1,5 +1,5 @@
 name:                esqueleto
-version:             1.0.2
+version:             1.0.3
 synopsis:            Bare bones, type-safe EDSL for SQL queries on persistent backends.
 homepage:            https://github.com/meteficha/esqueleto
 license:             BSD3
diff --git a/src/Database/Esqueleto/Internal/Sql.hs b/src/Database/Esqueleto/Internal/Sql.hs
--- a/src/Database/Esqueleto/Internal/Sql.hs
+++ b/src/Database/Esqueleto/Internal/Sql.hs
@@ -762,7 +762,7 @@
 makeOrderBy _    [] = mempty
 makeOrderBy conn os = first ("\nORDER BY " <>) $ uncommas' (map mk os)
   where
-    mk (EOrderBy t (ERaw _ f)) = first (<> orderByType t) (f conn)
+    mk (EOrderBy t (ERaw p f)) = first ((<> orderByType t) . parensM p) (f conn)
     orderByType ASC  = " ASC"
     orderByType DESC = " DESC"
 
diff --git a/test/Test.hs b/test/Test.hs
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -385,6 +385,21 @@
                  return p
           liftIO $ ret `shouldBe` [ p1e, p4e, p3e, p2e ]
 
+      it "works with a sub_select" $
+        run $ do
+          [p1k, p2k, p3k, p4k] <- mapM insert [p1, p2, p3, p4]
+          [b1k, b2k, b3k, b4k] <- mapM (insert . BlogPost "") [p1k, p2k, p3k, p4k]
+          ret <- select $
+                 from $ \b -> do
+                 orderBy [desc $ sub_select $
+                                 from $ \p -> do
+                                 where_ (p ^. PersonId ==. b ^. BlogPostAuthorId)
+                                 return (p ^. PersonName)
+                         ]
+                 return (b ^. BlogPostId)
+          liftIO $ ret `shouldBe` (Value <$> [b2k, b3k, b4k, b1k])
+
+
     describe "selectDistinct" $
       it "works on a simple example" $
         run $ do
