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 types of integrity are enforced by a foreign-key constraint

1 Answers  


What is Index ? Explain its Types?

2 Answers   ADP,


How to create indexed view?

0 Answers  


What is your recommendation for a query running very slow? : sql server database administration

0 Answers  


How to convert numeric expression data types by assignment operations?

0 Answers  






What is the Disadvantage of indexed sequential file.

0 Answers   HCL,


Explain activity monitors

0 Answers  


Explain steps of normalization?

0 Answers  


What are the all different types of Joins in SQL Server 2000, Anybody can explain each join with definition..Thanks in advance....

9 Answers   DELL, i Tech, Infosys, Siemens, TCS,


How to divide query output into multiple groups with the group by clause in ms sql server?

0 Answers  


How do you delete a trigger?

0 Answers  


what is differencial backup?how to work?Anybody explai it?

2 Answers   HCL,


Categories