Created
November 7, 2010 22:32
-
-
Save LauJensen/666980 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clojureql.core> (let [photo-counts (table {} :photos [:user_id [:count:* :as :cnt]])] | |
(-> (table {} :users [:*]) | |
(join photo-counts (= {:users.user_id :photos.user_id})) | |
compile)) | |
"SELECT users.*,photos_aggregation.cnt FROM users | |
LEFT OUTER JOIN | |
(SELECT photos.user_id,count(photos.*) AS cnt FROM photos GROUP BY user_id) | |
AS photos_aggregation ON (users.user_id = photos_aggregation.user_id)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment