SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 database query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

seenu1
Starting Member

1 Posts

Posted - 05/05/2013 :  07:04:53  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 05/06/2013 :  00:53:53  Show Profile  Reply with Quote
-- 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

India
52317 Posts

Posted - 05/06/2013 :  02:07:44  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000