sql - MySQL to PostgreSQL: GROUP BY issues -
So I decided to try PostgreSQL instead of MySQL, but I'm facing some minor conversion problems. It was a question to me that samples are from four tables and spit them out on the result.
How am I at the loss of expressing it in PostgreSQL and especially in Django, but I'm leaving for that one more quesiton so bonus points if you can Django-fy, but no Do not worry if you only pure it SQL
She began my first problems in that selection. It seems that this is true / wrong then the other stuff is the end IF so far I can not get the syntax right. I tried to use Navicat's SQL Builder, but it consistently wanted me to pick up all my things in Group Bye and I think it's all wrong.
What I'm seeing in brief is the MySQL query work in PostSyQL Thanks.
Current progress
Just want to thank everyone for their help
select links_link.id , links_link.created, links_link.url, links_link.title, links_category.title, sUM (links_vote.karma_delta) karma Yoga (as in: is it when the case I have done so far links_vote.user_id = 1 THEN links_vote.karma_delta ELSE 0 END) as to engage the upper Ovropr URL URI Link_link on auth_user oN (links_link.user_id = auth_user.id) lEFT OUTER join links_category oN (links_link.category_id = links_category.id) lEFT OUTER JOIN links_vote (links_vote.link_id = Links_link.id) Where (links_link.id = links_vote .link_id) links_link.id, links_link.created, links_link.url, links_link.title, command group links_link.created DESC limit 20 by links_category.title
I have to change a table name And I'm still working on my order till then we get out of the police. Thanks again!
Some things:
- Drop backticks < Li> IF ()
- Change your timestampdiff
DATE_TRUNC ( 'h', now ()) - DATE_TRUNC ( 'hour', links.created)
(you will result very easy to compare the need to calculate the number of hours in the gaps. timestamp) - Ordering by your group
instead of case use a case statement. Votes_id = 1 Then vote.karma_delta or else 0 end
Comments
Post a Comment