August 12, 2005 at 9:07 am
Is it possibel to get say any row from a table withotu havinga awhere condition. also teh tabel does have an identity colum. something like rownum =2. any help will be greatly apprecaited.
Thanks
August 12, 2005 at 9:11 am
Not enough details... sample data and required results please??
August 12, 2005 at 9:14 am
This will fetch a row but not the row in a row position. For that we must specify a where condition.
SET ROWCOUNT 1
SELECT * FROM myTable
OR
SELECT TOP 1 * FROM myTable
Can we ask why do you need such a select. Which row do you want to select without a where condition
Am I 3 minutes slower than Remi
Regards,
gova
August 12, 2005 at 9:18 am
"Am I 3 minutes slower than Remi "
That's almost a compliement to you .
August 12, 2005 at 9:18 am
I'm at least 3 minutes slower, if not more.
August 12, 2005 at 9:19 am
lets say you have 6 rows as follows. Is there a way i could get 5th row without using a where clause so that my results are EEE, 888. I know by adding an identity column this might help but any other way out? thanks
AAA 555
BBB 888
CCC 999
DDD 777
EEE 888
TTT 666
August 12, 2005 at 9:23 am
You can't filter squat without a where condition.
As for the 5th row, that's another problem altogether. What is the primary key of the table?
August 12, 2005 at 9:28 am
This is an unusual request indeed.
If you don't mind can you explain what you are trying to do?
What is the goal of writing a query without a where clause?
August 12, 2005 at 9:41 am
If this is what you want.
HTH
SET NOCOUNT ON
DECLARE @MyTable TABLE
(
MyName VARCHAR(10),
MyNum INT
)
INSERT @MyTable
SELECT 'AAA', 555 UNION
SELECT 'BBB', 888 UNION
SELECT 'CCC', 999 UNION
SELECT 'DDD', 777 UNION
SELECT 'EEE', 888 UNION
SELECT 'TTT', 666
SELECT MyName, MyNum
FROM
(
SELECT Rank = COUNT(*), T1.MyName, T1.MyNum
FROM
@MyTable T1, @MyTable T2
WHERE
T1.MyName >= T2.MyName
GROUP BY
T1.MyName, T1.MyNum) A
WHERE
Rank = 5
Regards,
gova
August 12, 2005 at 9:46 am
Thanks gusy i kneew this is indeed not diable unless you have an identity column and a where clause. BUt thought of checking up before i finally say abt this. thanks
August 12, 2005 at 10:01 am
Who requested this to you???
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply