Skip to content
Advertisement

How to change this coding from SQL Server to be in PostgreSQL [closed]

This query is running successfully using Microsoft SQL Server Management Studio and I could not use it in PostgreSQL. I want a similar query to give the same result using PostgreSQL Note that: this will run on a table that contains 1 junior and 2 seniors. I want to use this query also if I have more juniors and seniors

Advertisement

Answer

Your first mistake is assuming something runs in SQL Server it will Postgres (or any other DBMS) all the flow from that one. Further it is not a query it is a script, and the structure for a psql script is completely different from a T-sql script. I suggest you spend considerable time studying a couple Postgres Tutorials such as command line tutorial and PostgreSQLTutorial and/or others or !gasp! old technology – a book.

I appreciate that sometimes a problem is one of concept, like expecting a T-Sql script to run in Postgres. Therefore, I offer the following as a one-time demonstration to point you in the right direction. It is a translation to Postgres of your script, certainly not the only and perhaps not the best.

I leave its description to your research.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement