Skip to content

Select based on group membership

Suppose I have two tables t and o. I want to select all the rows of t in which t.feature = o.feature (ergo first two rows). In addition, I also want to select all the rows whose t.grouping = t.grouping of the previously selected rows. In this case t.grouping 1, 2 ergo rows (‘E’, 1), (‘F&#821…

Oracle SQL return column calculated from existing columns

I have the above SQL query which returns the columns name, X and Y. I would like to return one more column (lets call it Z) which gives the value of X/Y but not too sure how to do this – I tried writing (X/Y) Z but no luck – any suggestions? Answer Use CTE

Delete records with duplicates and join in another table

I need to write a query (Microsoft SQL Server) to delete duplicates in the table Vehicle that have Vehicle.CarId = Car.CarId and having the same concatenation (CarId, CounterLimit, Kilometers). Table Car: Table Vehicle: Could you please help me? Answer Joining the table creating the rank based on carid,counte…

Comparing two tables without foreign key [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question There are two tables in 2 different databases one table consists of Salutations example Mr, Mi…