write a query for list of owner who are having multiple
bikes in below table
1 shanker pulsar
2 shanker Honda
3 shanker car
4 Balu pulsar
5 Balu Honda
6 Balu car
7 Shyam pulsar
8 Jaya Honda
9 Deepa car
10 vasu car
Answer Posted / lakshmi narayanan r
CREATE TABLE bikes (bikeID INT, CName VARCHAR(50), BNAME
VARCHAR(50))
INSERT INTO bikes(CName, BNAME) VALUES ('shanker', 'pulsar')
INSERT INTO bikes(CName, BNAME) VALUES ('shanker', 'Honda')
INSERT INTO bikes(CName, BNAME) VALUES ('shanker', 'car')
INSERT INTO bikes(CName, BNAME) VALUES ('Balu', 'pulsar')
INSERT INTO bikes(CName, BNAME) VALUES ('Balu', 'Honda')
INSERT INTO bikes(CName, BNAME) VALUES ('Balu', 'car')
INSERT INTO bikes(CName, BNAME) VALUES ('Shyam', 'pulsar')
INSERT INTO bikes(CName, BNAME) VALUES ('Jaya', 'Honda')
INSERT INTO bikes(CName, BNAME) VALUES ('Deepa', 'car')
INSERT INTO bikes(CName, BNAME) VALUES ('vasu', 'car')
;WITH tmp (RowId, CName) AS (SELECT ROW_NUMBER() OVER
(PARTITION BY CName ORDER BY BikeID ASC) AS RowId, CName
FROM Bikes)
SELECT DISTINCT CName FROM tmp WHERE RowId > 1
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the difference between varchar and nvarchar datatypes?
How many categories of functions based their return modes?
How do you make a trace?
What is a full text index?
How to add additional conditions in SQL?
what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration
How would you go about developing a ssrs report?
Write a sql query to display the current date?
Write SQL queries on Self Join and Inner Join.
Differentiate between truncate vs delete in mssql?
What are the basic functions for master, msdb, model, tempdb and resource databases?
What is the difference between ‘having’ clause and a ‘where’ clause?
How many instances per computer are there in sql server 2000?
What is history table in sql server?
What is the use of =,==,=== operators?