Sql Operation:
SELECT *,
CASE
WHEN quota_unit = 'MB' THEN quota*1024
ELSE quota
END AS data_usage
FROM mapping
ORDER BY data_usage;
I tried like this,
query = mapping.select('CASE WHEN mapping.quota_unit = 'MB' THEN 1024 * mapping.quota ELSE mapping.quota END AS data_usage)
query.orderBy(data_usage)
res = list(query)
but select method taking that value in braces for Where clause and resultant query becomes
SELECT * FROM mapping WHERE 'CASE WHEN mapping.quota_unit = MB THEN 1024 * mapping.quota ELSE mapping.quota END AS data_usage'
which is not expected. Can you please me here ?