Posts

Showing posts with the label postgresql

Query results half right after joining two tables

The following query resulted in correct results only for the inner query (post_engagement, website purchases) while all other numbers were incorrectly increased manyfold. Any ideas? Thanks. Schema of the two tables: Favorite_ads (id, campaign_id, campaign_name, objective, impressions, spend) Actions (id, ads_id, action_type, value) Without knowing the actual table structure, constraints, dependencies and data, it's hard to tell, what the issue may be. You already have some leads in the comments, which you should consider first. For example you wrote, that this sub-query returns correct results: Is this one also giving correct results: If so, then try replacing your sub-query with that one. If you still have a problem, then I'd investigate if your join condition is correct, as it would seem, that for a campaign ( campaign_id ) you could probably have multiple entries with the same id , which will multiply the sub-query results - that depends on what is actually the primary key...

knex migration:latest cannot connect while psql works fine

I need help figuring out why I can't run knex migration on my local machine using. It seems that knex has some trouble connecting to the postgres database. Running knex migration:latest in the terminal gives me this error: I'm using postgres on my local Macbook. This is my knexfile: Running psql works fine: I'm running the command in the same directory that knexfile.js is in. Thank you! Your knexfile has an invalid syntax. You have not given the connection attribute there. It should look like this: By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.