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
 General SQL Server Forums
 New to SQL Server Programming
 How to get the first row from a Table

Author  Topic 

sfaiz82
Starting Member

4 Posts

Posted - 2009-08-28 : 02:22:17
Hi...I am new at this...I just have this new issue at work and thinking how to get this issue resolved....i have got a table B linked to another table A, where I want the 1st row of table B to be returned only...
i have got the following query...
SELECT     A.SERIES, A.ORMSTRNM, A.JRNENTRY, A.TRXDATE, A.ORDOCNUM, A.ACTINDX, 

GL00100.ACTNUMBR_1, GL00100.ACTNUMBR_2, GL00100.ACTNUMBR_3, A.DEBITAMT, A.CRDTAMNT, A.DSCRIPTN,

A.REFRENCE, A.ORMSTRID, RM00101.STMTNAME, POP30310.PONUMBER, POP10100.POPCONTNUM, B.PACONTNUMBER,

B.LNITMSEQ

FROM A INNER JOIN

GL00100 ON A.ACTINDX = GL00100.ACTINDX LEFT OUTER JOIN

B ON A.ORDOCNUM = B.PADocnumber20 LEFT OUTER JOIN

POP30310 INNER JOIN

POP10100 ON POP30310.PONUMBER = POP10100.PONUMBER ON A.SEQNUMBR = POP30310.RCPTLNNM AND

A.ORDOCNUM = POP30310.POPRCTNM LEFT OUTER JOIN

RM00101 ON A.ORMSTRID = RM00101.CUSTNMBR

WHERE (GL00100.ACTNUMBR_3 = '41011') AND (A.TRXDATE BETWEEN CONVERT(DATETIME, '2009-07-01 00:00:00', 102) AND CONVERT(DATETIME,

'2009-07-31 00:00:00', 102)) AND (A.ORDOCNUM = 'PRINV010871'))


All I want is to get the first row to be considered from the table 'B'...When the link between Table A and Table B is done, I want it to work with only the first row of Table 'B', not the rest of Table 'B' rows...what can I do to achive this....need help on this at the earliest....Thanks....

--------------

Sayed Faiz

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-08-28 : 02:25:52
quote:
the 1st row of table B to be returned only

what determine the row is the first row?date, id?


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

sfaiz82
Starting Member

4 Posts

Posted - 2009-08-28 : 02:31:08
B.PACONTNUMBER is the field from table B, for which I want the first row to be considered....

--------------

Sayed Faiz
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-28 : 02:41:44
New?
Same table structure and table name and column names here for a "fellow australian".
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=68329&whichpage=1



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

sfaiz82
Starting Member

4 Posts

Posted - 2009-08-28 : 12:14:44
i need the first record of that field which has the lowest value....

quote:
Originally posted by waterduck

quote:
the 1st row of table B to be returned only

what determine the row is the first row?date, id?


Hope can help...but advise to wait pros with confirmation...



--------------

Sayed Faiz
Go to Top of Page

sfaiz82
Starting Member

4 Posts

Posted - 2009-08-30 : 19:38:54
can anyone still provide me some clue on how cn i do this???..if you show me the function in sql for doing this...and how the function needs to be used then that would be useful...i will then apply that to my query....thanks...

--------------

Sayed Faiz
Go to Top of Page
   

- Advertisement -