New answers tagged

0

You can simoly put around the Select ... ORDER BY RAND() in parenthesis, so that MysSQL knows how to process it (SELECT * FROM ( SELECT hobber_deal_page.id, hobber_deal_page.merchant_id, hobber_deal_page.category_id, hobber_deal_page.emirate_id, hobber_deal_page.title, hobber_deal_page.description, ...


0

Seems like I had to use a larger subquery and join it with the main query. Works fine this way. Not sure why it did not work the above way though... SELECT tags_x.tag_id, tags.tag_name, questions.question_id,X.num FROM tags_x LEFT JOIN tags ON tags.tag_id = tags_x.tag_id LEFT JOIN questions ON questions.question_id = tags_x.question_id LEFT JOIN (SELECT ...


0

You need to do the currency conversion within the aggregate function SELECT CASE WHEN DATEDIFF(campaign.deadline,campaign.launched)<=30 THEN 'Short Campaign' WHEN DATEDIFF(campaign.deadline,campaign.launched)>30 AND DATEDIFF(campaign.deadline,campaign.launched)<=60 THEN 'Mid-lengthed Campaign' ELSE 'Long Campaign' END AS 'Campaign ...


0

A syntactical version that should work (untested due to lack of ddl and sample data) is: SELECT CASE WHEN DATEDIFF(campaign.deadline,campaign.launched)<=30 THEN 'Short Campaign' WHEN DATEDIFF(campaign.deadline,campaign.launched)>30 AND DATEDIFF(campaign.deadline,campaign.launched)<=60 THEN 'Mid-lengthed Campaign' ELSE 'Long Campaign' ...


1

Use a left join: select up.id, r.element ->>'subject' as result from "UserProfile" up left join jsonb_array_elements(up.result) as r(element) on true


Top 50 recent answers are included