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
 selecting one row from a 1 column table

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-04-11 : 06:16:17
Good morning.

I have a basic table

create table IndividualTotals (

count int null )

Count
3435
334
11
99
3

Now is there a way i can select row 2 or 3 with out having to insert
an identity column. This table changes throughout the day and is referenced in an excel sheet to populate a fancy report. people just wont move away from excel.

MCTS / MCITP certified

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2011-04-11 : 06:20:41
How you are deciding 2nd and 3rd row ?
On the basis of order by which column ?
anyways try this -

SELECT Count, ROW_NUMBER OVER( ORDER BY ( SELECT 1 ) ) Seq FROM IndividualTotals



Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-04-11 : 06:36:57
thank you

I am trying to get the first value in the sequence with the following code.

SELECT [count], ROW_NUMBER() OVER( ORDER BY ( SELECT 1 ) ) seq FROM IndividualTotals


where seq = 1

but i am receiving the following message.

Msg 207, Level 16, State 1, Line 4
Invalid column name 'seq'.
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-04-11 : 07:01:47
Its ok. Ive sorted it thank you for you quick reply Vaibhav T


Nice one
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2011-04-11 : 09:28:18
You are welcome

Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page
   

- Advertisement -