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
Answers were Sorted based on User's Feedback
Answer / priestly george varghese
Select Count(*) as Bike_Count, Owmer from <TN> where Bike
in('pulsar','Honda')
group by Owmer having count(*)>1
| Is This Answer Correct ? | 8 Yes | 1 No |
Answer / anil
select ownername,count(bike) noofbikes from abikes group by ownername having Count(bike)>1
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / valibasha
Select owner from table where bike in(‘pulsar’,’Honda’) group by owner having count(*)>=1
| Is This Answer Correct ? | 7 Yes | 5 No |
Answer / gaurav.verma4210
select count(*) as no_of_vehical,owner from MulBike group by owner having count(*)>=1
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / 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 |
Answer / anand
hey thanks a lot, it is working but with slight modification
Select Count(*) as No-Vehicles, owner from table where
group by owner having count(*)>=1
Regards,
Anand
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / gangadharrao
select Owner from dbo.[table] where Bike in (select bike
from dbo.[table]) group by owner having count(*) >1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vidhya
select count(*) as no_of_vehical,owner_name from vehicles group by owner_name having count(*)>=1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / aditya
select name
from ( select name from bikehaving
where drive in ('pulsur',Homda')) xxx
group by name
having name > 1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rajkumar v
select Owner, COUNT(*) as Total from table_name group by
Owner having COUNT(*)>1
| Is This Answer Correct ? | 0 Yes | 0 No |
What are commit and rollback in sql?
What is lookup override?
How do I run sql server 2014?
Can you insert NULL in unique column?
Would it be a good idea to create an index on a table that always contains 10 records? Why or why not?
How many database files are there in sql server 2000?what are they?
What are joins in sql and what are the different types of joins?
how to improve the speed of SQL database server and how to avoid dead lock?
When do you create cluster and noncluster index?
explain different levels of normalization? : Sql server database administration
What are the Advantages of using CTE in sql server?
is there more the two primary key in a single table?
26 Answers Eforce, Systematix,
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)