Skip to content

Tag: sql

Remove characters after space in sql

I have two tables as shown below: I would like to match these two columns i.e FIRST_NAME from table1 to FIRSTNAME from table2. I tried with the below query but only could match Richard and not Kristin. Please suggest! Answer I would add trim to make sure there’s no whitespace preventing a match.

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…