Solved

value of field in position n

Posted on 2012-03-23
6
250 Views
Last Modified: 2012-03-28
Hi there,

Let´s say I have a table XYZ with 2 fields and 3 records, say:

field1   field2
1               car
32             dog
123           cat

I want to select 'cat' with an SQL statement like:

"select field2  from tableXYZ where field1 = [value of field1 in n-row] order by field1 asc"

My question is: how should I "fill the bold place", please?

(I want  a general solution to this case, in which I am able to find which is the number present in the record of field1 when we are looking at the n-th row, where n is given.)

Thanks,
fskilnik.
0
Comment
Question by:fskilnik
  • 4
  • 2
6 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 37757299
What do you mean the "nth" row?  is n the value of field1?  I'm guessing not but if so, it would just be n for your bold area:
select field2  from tableXYZ where field1 =n order by field1 asc

If n refers to an ID column in your table it would work like this
select field2  from tableXYZ where ID = n
0
 

Author Comment

by:fskilnik
ID: 37758801
The problem refers to your second interpretation (of course), but your suggestion does not work, because there is NO "ID" column with this name, although I WANT to do what you suggested... in other words, the problem is how to use the number of the line if the counter óf the number of the line involved is not a field itself... I hope you understood my difficulty.
0
 

Accepted Solution

by:
fskilnik earned 0 total points
ID: 37759228
I was looking at an "SQL array"... and I found the question and the solution at this EE link.

link: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_20628476.html

Thank you anyway.
fskilnik.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 18

Expert Comment

by:UnifiedIS
ID: 37759843
Ah, and therein lies the problem with EE.  My effort is provided without cost to EE or the poser of the question.
0
 

Author Comment

by:fskilnik
ID: 37761197
@UnifiedIS: I am really surprised with your complaint, because I have been here at EE for many many years and your first reply showed me you took VERY little time even to understand my question (in my opinion), what is something ENORMOUSLY UNUSUAL in my EE experience, by the way.

(Sometimes I would like to give 5,000 points to the experts, not only the 500 permitted. It was certainly not the case here, simply because I could see no use to the "solution" you have provided.)

Even so, if you would like to (and if the moderator agrees), I would be glad to give you the 500 points as a compensation to your effort (your word, no pun-intended).
0
 

Author Closing Comment

by:fskilnik
ID: 37775759
(I guess I found the solution myself.)
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question