dbTalk Databases Forums  

Help with sql

comp.databases.sybase comp.databases.sybase


Discuss Help with sql in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ars
 
Posts: n/a

Default Help with sql - 11-05-2003 , 01:05 PM






Hi All,

I need help in writing a query to get the first row of the following query
result.

1> select db_name, smiNumber,xyz = datediff(day,db_start_date, getdate()),
pubname from publication p, db_pub_table dp, db_table d
2> where p.Id = dp.pub_id
3> and dp.db_id = d.db_id
4> and journalcode = "NYT"
5> go
db_name smiNumber xyz pubname
---------- --------- ----------- ------------------------------------------
----------------------------------------------------------
Y041 30ba 157 The New York Times
0DIM 30ba 8709 The New York Times
0FEE 30ba 8343 The New York Times
0EVV 30ba 7978 The New York Times
0EVW 30ba 7613 The New York Times

(5 rows affected)






Reply With Quote
  #2  
Old   
Joe Weinstein
 
Posts: n/a

Default Re: Help with sql - 11-05-2003 , 02:37 PM








ars wrote:

Quote:
Hi All,

I need help in writing a query to get the first row of the following query
result.

1> select db_name, smiNumber,xyz = datediff(day,db_start_date, getdate()),
pubname from publication p, db_pub_table dp, db_table d
2> where p.Id = dp.pub_id
3> and dp.db_id = d.db_id
4> and journalcode = "NYT"
5> go
db_name smiNumber xyz pubname
---------- --------- ----------- ------------------------------------------
----------------------------------------------------------
Y041 30ba 157 The New York Times
0DIM 30ba 8709 The New York Times
0FEE 30ba 8343 The New York Times
0EVV 30ba 7978 The New York Times
0EVW 30ba 7613 The New York Times

(5 rows affected)
How about:
select db_name, smiNumber,xyz = datediff(day,db_start_date, getdate()),
pubname from publication p, db_pub_table dp, db_table d
where p.Id = dp.pub_id
and dp.db_id = d.db_id
and journalcode = "NYT"
and db_name = "Y041"
and smiNumber = "30ba"
and pubname = "The New York Times"

hahahaha, I crack myself up!!!
Ok, now I feel better... If you can't use 'set rowcount',
can you guarantee that these rows are all unique? It doesn't
seem so. Is there any real order in these rows? What is special
about that first row?

Joe Weinstein at BEA




Reply With Quote
  #3  
Old   
ars
 
Posts: n/a

Default Re: Help with sql - 11-07-2003 , 07:43 AM



Hi Joe, Thanks for your inputs, I used set rowcount and got my issue
resoled. As for what is speciall the first row? first row has the minimum
xyz and that is what I am after. Thanks again, Ahmad Salehi
"Joe Weinstein" <joeNOSPAM (AT) bea (DOT) com> wrote

Quote:

ars wrote:

Hi All,

I need help in writing a query to get the first row of the following
query
result.

1> select db_name, smiNumber,xyz = datediff(day,db_start_date,
getdate()),
pubname from publication p, db_pub_table dp, db_table d
2> where p.Id = dp.pub_id
3> and dp.db_id = d.db_id
4> and journalcode = "NYT"
5> go
db_name smiNumber xyz pubname

---------- --------- ----------- ----------------------------------------
--
----------------------------------------------------------
Y041 30ba 157 The New York Times
0DIM 30ba 8709 The New York Times
0FEE 30ba 8343 The New York Times
0EVV 30ba 7978 The New York Times
0EVW 30ba 7613 The New York Times

(5 rows affected)

How about:
select db_name, smiNumber,xyz = datediff(day,db_start_date, getdate()),
pubname from publication p, db_pub_table dp, db_table d
where p.Id = dp.pub_id
and dp.db_id = d.db_id
and journalcode = "NYT"
and db_name = "Y041"
and smiNumber = "30ba"
and pubname = "The New York Times"

hahahaha, I crack myself up!!!
Ok, now I feel better... If you can't use 'set rowcount',
can you guarantee that these rows are all unique? It doesn't
seem so. Is there any real order in these rows? What is special
about that first row?

Joe Weinstein at BEA





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.