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



write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

Answer / anil

select ownername,count(bike) noofbikes from abikes group by ownername having Count(bike)>1

Is This Answer Correct ?    4 Yes 1 No

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

write a query for list of owner who are having multiple bikes in below table 1 shanker pulsar 2 ..

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

Post New Answer

More SQL Server Interview Questions

How do indexes help, types?

0 Answers  


How to get @@error and @@rowcount at the same time?

0 Answers  


According to you what goes into making the best database administrator? : sql server database administration

0 Answers  


When do u use clustered index and non-clustered index?

3 Answers   IBM,


How to create a large table with random data for index testing in ms sql server?

0 Answers  






Is it possible to create a stored procedure that runs a query and outputs the results to a text file and allows me to add extra delimeters and static field info. If so How?

1 Answers  


Can primary key be null?

0 Answers  


select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.

8 Answers   TCS,


What are the ways available in sql server to execute sql statements?

0 Answers  


What is the STUFF function and how does it differ from the REPLACE function?

2 Answers  


If we use where clause in the left outer join then how the query would behave/act?

1 Answers  


on line cluster can we make if yes tell me the procedure

0 Answers   Microsoft,


Categories