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 should we do to copy the tables, schema and views from one SQL Server to another?

3 Answers  


What is buffer cash and log cache in sql server?

0 Answers  


What new changes are being made in SQL Server?

0 Answers   Blue Star,


What is the recovery model? List the types of recovery model available in sql server?

0 Answers  


two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd table EmpSal has 2 columns ID and Salary Contains data -1,1000 2,5000 3,3000 Find name of employee having maximum salary ?

5 Answers   CSE,






What is the contrast between sql and mysql?

0 Answers  


What is use of except clause?

0 Answers  


What is difference between views and stored procedures?

0 Answers  


How to concatenate two binary strings together?

0 Answers  


What is subquery in sql?

0 Answers  


when inserting to a table how many rows will be effected using triggers

2 Answers  


How can we determine what objects a user-defined function depends upon?

0 Answers  


Categories