469,142 Members | 1,112 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,142 developers. It's quick & easy.

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
3 Weeks Ago #1
1 3805
9,061 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
3 Weeks Ago #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 zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.