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 2000 Forums
 SQL Server Development (2000)
 getting only first row for each company
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 06/05/2006 :  06:25:01  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
i have 2 table
1 with id's of companies
2 with a list of stock owner for each company where : ownerid,companyid

how can i get for each company not all the rows but only the first row for each 1 of them
thnaks in advance
peleg


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 06/05/2006 :  06:28:38  Show Profile  Reply with Quote
What is first row ? You have to define this. Records is not store in any particular order in the database. So there isn't FIRST or LAST record. The ordering of record is defined by the ORDER BY clause in the SELECT statement.


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 06/05/2006 :  06:29:40  Show Profile  Reply with Quote
Also post the table structure, some sample data and the result that you want


KH

Go to Top of Page

pelegk2
Aged Yak Warrior

Israel
723 Posts

Posted - 06/05/2006 :  06:46:54  Show Profile  Visit pelegk2's Homepage  Send pelegk2 an ICQ Message  Reply with Quote
ok little change
i want for each companyu in the same row all the sotck owner like thos
table1.companyid,table2.stockownername1,table2.stockownername2....
how can i do this?

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 06/05/2006 :  06:54:27  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Refer point 2
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RyanRandall
Flowing Fount of Yak Knowledge

United Kingdom
1074 Posts

Posted - 06/05/2006 :  07:12:21  Show Profile  Reply with Quote
pelegk2 - It sounds to me like you might want a crosstab/pivot - in which case I give you the usual links...

http://www.sqlteam.com/item.asp?ItemID=2955
http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx

BUT it's hard to figure out what you're asking without an example. Please post as khtan has asked (table structure, some sample data and the result that you want)...


Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
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.08 seconds. Powered By: Snitz Forums 2000