Reputation:
I cannot figure out what would be the correct syntax for aliasing a field in the SQL query builder in clsql.
Below is an example, as I would imagine it might work (but obviously it doesn't):
(defun number-of-goods-you-have-the-most? ()
(clsql:select [item_id] [as [count [*]] 'num]
:from [table]
:where [is [null [sale_date]]]
:group-by [item_id]
:order-by '((num :desc))
:limit 1))
I could've make it something like '|count(*) as num|
but that's surely not the way to do it.
Upvotes: 2
Views: 147
Reputation: 899
Could you try (clsql:select [item_id] [count [*]] [as] 'num] ...)
?
Upvotes: 1