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.
Author |
Topic |
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-06-05 : 06:25:01
|
i have 2 table1 with id's of companies2 with a list of stock owner for each company where : ownerid,companyidhow can i get for each company not all the rows but only the first row for each 1 of themthnaks in advancepelegIsrael -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 |
|
|
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 |
|
|
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 thostable1.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 -:) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
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=2955http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspxBUT 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 Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
|
|
|
|
|