Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 database query

Author  Topic 

seenu1
Starting Member

1 Post

Posted - 2013-05-05 : 07:04:53
Hi ,
database with a table of stocks and another table of clients. How would to write a query that lists all clients and then for each client all the stocks that that client holds? please Explain each of the elements of your SQL statement and why we are choosing to use them. What would happen if a given client has no holdings? How the database to improve the performance of such a query?


Seenu

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-06 : 00:53:53
-- Lists all clients along with stocks...
SELECT *
FROM stocks s
JOIN clients c
ON s.client_id = c.client_id

Refer the following link for different types of results
http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-06 : 02:07:44
quote:
Originally posted by seenu1

Hi ,
database with a table of stocks and another table of clients. How would to write a query that lists all clients and then for each client all the stocks that that client holds? please Explain each of the elements of your SQL statement and why we are choosing to use them. What would happen if a given client has no holdings? How the database to improve the performance of such a query?


Seenu


Sounds like an assignment to me

Please show what you've tried so far. Otherwise we're not going to spoonfeed you with the solutions

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -