Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

value of field in position n

Posted on 2012-03-23
6
Medium Priority
?
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

670 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