Give bookname which is more then one time and number of books also
create table books
(
id int identity(1,1),
custname varchar(25),
bookname varchar(25)
)
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'naimish', N'five point someone')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'ravi', N'five point someone')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'jugal', N'five point someone')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'jugal', N'3 mistakes of my life ')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'naimish', N'3 mistakes of my life ')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'nikhi', N'satya na prayogo')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'ram', N'ravan')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'misi', N'evil')
INSERT [dbo].[books] ( [custname], [bookname]) VALUES ( N'michel', N'evil')
like this.
SELECT COUNT(BOOKNAME)NoofBooksales,BOOKNAME
ReplyDeleteFROM BOOKS
GROUP BY BOOKNAME
HAVING COUNT(BOOKNAME)>1
exactly..
Delete