Solved

value of field in position n

Posted on 2012-03-23
6
244 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 18

Expert Comment

by:UnifiedIS
Comment Utility
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
Comment Utility
@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
Comment Utility
(I guess I found the solution myself.)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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 setup several different housekeeping processes for a SQL Server.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now