471,853 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

first time code help - PostgreSQL help


I have written code in T-Sql used code converter for PostgreSQL, got below code but it is giving complier error. I have no clue in PostgreSQL so any pointer will be of great help.
Expand|Select|Wrap|Line Numbers
  1. select t.team_id, t.team_name,COALESCE(SUM(num_points),0) num_points from 
  2.    (select team_id, host_team, 3 into team_name, num_points   -----syntax error at or near ","
  3.                                                                                      -----LINE 3:    (select team_id, host_team, 3 into team_name, num_points
  5.    from matches m
  6.    inner join teams t on m.host_team = t.team_id
  7.    where host_goals > guest_goals
  8.    Union All
  9.     select team_id, guest_team,  3 into team_name, num_points
  10.    from matches m
  11.    inner join teams t on m.guest_team = t.team_id
  12.    where guest_goals > host_goals
  13.    Union All 
  14.     select team_id, guest_team,  1 into team_name, num_points
  15.    from matches m
  16.    inner join teams t on m.guest_team = t.team_id
  17.    where guest_goals = host_goals
  18.     Union All 
  19.     select team_id, host_team,  1 into team_name, num_points
  20.    from matches m
  21.    inner join teams t on m.host_team = t.team_id
  22.    where guest_goals = host_goals)
  23.    r
  24.    right outer join teams t on r.team_id = t.team_id
  25.    group by  t.team_id, t.team_name
  26.    order by 1
Aug 30 '21 #1
1 4759
9,065 Expert Mod 8TB
That is a long and complicated statement, I would break it down and test smaller parts of it.

Alternatively rather than translation from T-SQL I would determine what I wanted to do and re-write it directly in postgresql
Aug 31 '21 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Steve Bishop | last post: by
11 posts views Thread by Jason | last post: by
3 posts views Thread by goldie11 | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.