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 do you understand by triggers and mention the different types of it?

0 Answers  


How to add an address record into adventureworkslt?

0 Answers  


Can we use Truncate command on a table which is referenced by FOREIGN KEY?

2 Answers   Shriram,


what's the difference between SQL & MY-SQl...? And what we learn from these ....?

2 Answers   Broadridge,


How to execute stored procedure in select statement sql server?

0 Answers  






You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

0 Answers  


How to create an multi-statement table-valued function?

0 Answers  


What is difference between process and thread? Explain lazy writer funcationality.

2 Answers   Microsoft,


how can you check the level of fragmentation on a table? : Sql server administration

0 Answers  


What is the difference between coalesce() & isnull()?

0 Answers  


what are defaults? : Sql server database administration

0 Answers  


What is the contrast between sql and pl/sql?

0 Answers  


Categories