Table - Products has number of products as below
Productid ProductName
1
iPhone
2
iPad
3
BlackBerry

Table - SalesPersonProduct has the
below records
Salespersonid
productid
S1
1
S1
2
S1
3
S2
1
S3
2

Write a SQL query that returns the number of sales for each
product

Answers were Sorted based on User's Feedback



Table - Products has number of products as below Productid ..

Answer / subbareddy.l

Hi,

This query will give us number of sales product wise


select SPP.Productid,COUNT(SPP.Productid)CC from
SalesPersonProduct SPP inner join products P
ON SPP.Productid=P.Productid
group by SPP.Productid

Thanks,
subbareddy.l

Is This Answer Correct ?    5 Yes 0 No

Table - Products has number of products as below Productid ..

Answer / madhu sudhan g

Hiii

try this query you will get the answer

select count(1) as SalesCount,P.Product from Products P
INNER JOIN SalesPersonProduct S ON S.Id=p.Id group by P.Product

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL Server Interview Questions

what is sql injection in sql server?

2 Answers   TATA,


could u plz explain about joins and views?

2 Answers  


WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?

8 Answers  


what is blocking? : Sql server database administration

0 Answers  


what is the query and condition to delete datas in sql server.

2 Answers  






what is the maximum size of a row? : Sql server database administration

0 Answers  


What are the acid properties?

0 Answers  


What are the differences between char and nchar in ms sql server?

0 Answers  


Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input of particular value in a column of a table?

3 Answers   Accenture,


Create Index myIndex On myTable(myColumn) What type of Index will get created after executing the above statement

3 Answers  


what are the steps you will take to improve performance of a poor performing query? : Sql server database administration

0 Answers  


What is sql server locking?

0 Answers  


Categories