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
 Newbie here

Author  Topic 

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-03-31 : 18:58:00
I have a statement that shows like this:

SELECT TOP 1 symptom,ResolutionID, ResolutionTitle, PhoneBrand,ResolutionDetails1, case when (resolution_A)*1.0 = '0' then '0' else (resolution)*1.0/(resolution_A) *1.0 end AS RFR FROM dbo.GlobeKB_KMT3

It has more than 10 results. Is it possible to show only the the 7th row? thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-31 : 19:01:22
If you are using SQL Server 2005 or 2008, then you can use the ROW_NUMBER() function to get that 7th row.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-03-31 : 21:43:59
I'm only using 2000. Would that still possible?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-03-31 : 21:47:16
Unfortunately no, but you could try this:

http://www.sqlteam.com/article/whats-after-top
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-04-01 : 03:09:34
it's not working..is it possible to just get the 7th row only?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-01 : 03:58:28
quote:
Originally posted by BankOfficerHere

it's not working..is it possible to just get the 7th row only?


Show us the code that is not working

Madhivanan

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

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-04-01 : 04:10:14
SELECT TOP 1 symptom,ResolutionID, ResolutionTitle, PhoneBrand,ResolutionDetails1, case when (resolution_A)*1.0 = '0' then '0' else (resolution)*1.0/(resolution_A) *1.0 end AS RFR FROM dbo.GlobeKB_KMT3

I just want to show row 7 alone
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-01 : 04:28:46
on which basis u divide rows mean on which basis u divide 7 row....
but like that ..may be

select top 1 from (select top 7 from .. order by urcolumn desc)t order by urfield desc
May Be this gonna solve ur Problem
Thanks...
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-04-01 : 05:01:42
i tried that but i think Dreamweaver does not accept Top1
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-01 : 07:36:25
u jus do it in your sql ...
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-04-01 : 07:37:52
it's there another way?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-01 : 07:42:07
Not really, this is the simplest way to do it in SQL 2000.

May I ask what's so important about the 7th row? Also, why are you using Dreamweaver? If Dreamweaver does not support this syntax you can create a stored procedure with the correct SQL and then execute that stored procedure.
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-04-01 : 07:44:13
yeah it's important
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-01 : 07:45:35
Yes this The Best Way to do this,,, fo r u r working in Dream Viewer than Jus make A Store Procedure of that thing and Just call that procedure from your application and this procedure u also able to choose that which row u want exactly by a little bit of modification....

So just prepare a procedure for that purpose,,,
Thanks...
Go to Top of Page
   

- Advertisement -