473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Query genus required

In my code below the result returns two rows. This particular Tenant occupys
2 Units. How do I join the two rows to give me "Unit1 and Unit4"

ALTER PROCEDURE dbo.getUnitNumbers
@TenantID int,

@UnitNumber varchar(50) OUTPUT

as

SELECT TOP (8) @UnitNumber = UnitNumber

FROM Area

WHERE (TenantID = @TenantID)

ORDER BY UnitNumber
Jan 4 '07 #1
3 769
I don't think you can do that with a single SELECT query. It may be
better to count the number of rows returned, and if it's more than one
loop through them and concatenate the string yourself.

Carol

Ivan Jericevich wrote:
In my code below the result returns two rows. This particular Tenant occupys
2 Units. How do I join the two rows to give me "Unit1 and Unit4"

ALTER PROCEDURE dbo.getUnitNumbers
@TenantID int,

@UnitNumber varchar(50) OUTPUT

as

SELECT TOP (8) @UnitNumber = UnitNumber

FROM Area

WHERE (TenantID = @TenantID)

ORDER BY UnitNumber
Jan 4 '07 #2
Thanks Carol, I had the assumption it would be something like this. But I
simply don't know how to ask it to just that.
<cw*******@london.eduwrote in message
news:11**********************@s34g2000cwa.googlegr oups.com...
>I don't think you can do that with a single SELECT query. It may be
better to count the number of rows returned, and if it's more than one
loop through them and concatenate the string yourself.

Carol

Ivan Jericevich wrote:
>In my code below the result returns two rows. This particular Tenant
occupys
2 Units. How do I join the two rows to give me "Unit1 and Unit4"

ALTER PROCEDURE dbo.getUnitNumbers
@TenantID int,

@UnitNumber varchar(50) OUTPUT

as

SELECT TOP (8) @UnitNumber = UnitNumber

FROM Area

WHERE (TenantID = @TenantID)

ORDER BY UnitNumber

Jan 4 '07 #3
Try posting this to microsoft.public.sqlserver.programming.
I think they will know how to do this, and if it definitely
can't be done, they'll tell you that, too. I'm assuming this
is SQLServer? I would post the version you are using, as
well as the DDL for creating the tables, or the table
structures.

Robin S.
-----------------------------------
"Ivan Jericevich" <iv**@oberon.co.zawrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
In my code below the result returns two rows. This particular Tenant
occupys 2 Units. How do I join the two rows to give me "Unit1 and
Unit4"

ALTER PROCEDURE dbo.getUnitNumbers
@TenantID int,

@UnitNumber varchar(50) OUTPUT

as

SELECT TOP (8) @UnitNumber = UnitNumber

FROM Area

WHERE (TenantID = @TenantID)

ORDER BY UnitNumber


Jan 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tim Pascoe | last post by:
I have a database which stores information about organisms collected during sediment toxicology research. For each sample, organisms in sediment are collected and identified taxonomically (Order,...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
2
by: D Newsham | last post by:
I am trying to run an update query and am having problems with null values. Starting from the beginning - I created a new table from my original table, selecting distinct combinations of these...
6
by: Maital | last post by:
Dear experts, I'm a beginner with ms-access. I have data from 3 years of observations on a certain field, divided into North and South sections. The first table has information for about 600...
2
by: Venk | last post by:
hi all, I saw one reply to arun on the subject "Dynamic Query in Ms-Access" by one Mr Rick I found it very useful. Now to extend this solution forward I have the following situation. I...
1
by: mrkselm | last post by:
Hi, I am stuck with a problem in MS Access which does not occur in SQL Server and I have been banging my head against the wall for a couple of days now trying to resolve it. Namely, when I...
4
by: dipperdan | last post by:
Hi, I am working on a plant database and I need some help with a query that i *thought* shouldn't have been too hard =\ I am trying to create a query that will display the names contained in 4...
46
by: OldBirdman | last post by:
What a mess this question is. I have spent 2 weeks trying to make it concise and clear, and I can't. I do not have the vocabulary for the question. I cannot even TITLE it correctly. Here is my...
16
by: OldBirdman | last post by:
I have tables to contain the names of the birds of the world. tGN - Genus scientific (Latin) names Key (PK) autonum Ptr->FA (FK) pointer to key in table=FA Not used in this problem...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.