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 2000 Forums
 SQL Server Development (2000)
 getting only first row for each company

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-06-05 : 06:25:01
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)

17689 Posts

Posted - 2006-06-05 : 06:28:38
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)

17689 Posts

Posted - 2006-06-05 : 06:29:40
Also post the table structure, some sample data and the result that you want


KH

Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-06-05 : 06:46:54
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

22864 Posts

Posted - 2006-06-05 : 06:54:27
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
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-05 : 07:12:21
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
   

- Advertisement -