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

how to avoid cursors? : Sql server database administration

0 Answers  


What is index, cluster index and nonclustered index?

0 Answers  


SQL Server Performance Tuning for Stored Procedures & reducing debugging time?

1 Answers   CarrizalSoft Technologies,


What stored procedure would you use to view lock information?

0 Answers  


Can we create a clustered index on composite primary key.

3 Answers   IGT,






What is a transaction and what are ACID properties?

3 Answers  


I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that

0 Answers  


What is pivot and unpivot?

0 Answers  


Difference between 2NF &3NF ?

0 Answers   Cap Gemini,


Questions regarding Raiseerror?

1 Answers  


explain databases and sql server databases architecture? : Sql server database administration

0 Answers  


is there more the two primary key in a single table?

26 Answers   Eforce, Systematix,


Categories