?
Solved

Select value from first row where

Posted on 2010-01-05
3
Medium Priority
?
159 Views
Last Modified: 2012-05-08
I have a table with following columns: Id,  AId, BId
I would like to select the value in AId from the first row where BId=@BId. How do I do that?
0
Comment
Question by:johnkainn
3 Comments
 
LVL 4

Accepted Solution

by:
igni7e earned 336 total points
ID: 26185378
select top 1 ald from table where bld=@bld
0
 
LVL 26

Assisted Solution

by:tigin44
tigin44 earned 332 total points
ID: 26185381
select top 1 AId
from yourTable
where  BId=@BId
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 332 total points
ID: 26185393
"first row" is ambiguous...first has to be based on something...so you'd need an order by

select top 1 AId
from yourTable
where  BId=@BId
order by AId
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

850 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