Skip to content

How to select only latest added records avoiding duplicates

I need to select from the table competition_rounds the latest added records which are linked to the competition_seasons table with the season_id column, eg: competition_rounds competition_seasons I want return only: the problem’s that my query return all rounds available: NB: The table competition simpl…

Postgres get root of self-referential table

Given the table: If I get a name from the table (and thus the Pkey), how can I get the name of it’s “root”-level parent: the name where parent is NULL which is referenced to (indirectly) by the given name. Say I have these values (I don’t know which values I will get): The function/wha…

SQL Query to Show When Golfer Not Attached to an Event/Year

I am working on a school assignment that has downright stumped me for days. The task is to, using a view (VAvailableGolfers), populate a list box with Golfers who are not tied to a given event/year selected from a combo box. Here is the data in the tables: The expected output on the form, then, would be: 2015…

sql Query support required for condition

I have a query if vatgroup chooses x6 or x7 in output has to show ‘-‘ other than than it has to show the value what is come. Based on below query my output comes as * for other than x6 or x7. Thanks Vinoth Answer You are casting your integer sum to varchar(1) which means if the sum is

Finding couples of occurrences – Postgresql

I need to find possible couplings of employees and department that they worked for. I need to include only the couplings of 2 different departments, so if an employee worked for more than 2 …

SQL Select or join two separate subsets of a table

Say I have a table Element in my SQL Server database with, we’ll suppose, nothing other than an Id column. I also have tables Foo and Bar, which each have a many-to-many relationship with Element, …