473,387 Members | 1,592 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,387 software developers and data experts.

Select returns one row from two

Goodmorning,
Could I have a SELECT statement that normally returns two rows
,but that instead returns one row appending to the first row the second
one of the result ?
For example

Query: "SELECT username from tab1 where year in (2001,2002)"

Result:
1° - "'John'"
2° - "'Adam'"

Instead I need:

Result:
"'John','Adam'"?

I have Win2000 Pro , SqlServer2000.

Thank You

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 20 '05 #1
3 1113
"Rocky XXVIII" <al*******@hotmail.com> wrote in message news:<1c*************************************@myga te.mailgate.org>...
Goodmorning,
Could I have a SELECT statement that normally returns two rows
,but that instead returns one row appending to the first row the second
one of the result ?
For example

Query: "SELECT username from tab1 where year in (2001,2002)"

Result:
1° - "'John'"
2° - "'Adam'"

Instead I need:

Result:
"'John','Adam'"?

I have Win2000 Pro , SqlServer2000.

Thank You

You could do this:

SELECT a.username & ',' & b.username from tab1 a, tab1 b where a.year
=2001 and b.year = 2002;

Could add ' as needed or trims.
Jul 20 '05 #2
On Tue, 12 Oct 2004 08:58:29 +0000 (UTC), Rocky XXVIII wrote:
Goodmorning,
Could I have a SELECT statement that normally returns two rows
,but that instead returns one row appending to the first row the second
one of the result ?
For example

Query: "SELECT username from tab1 where year in (2001,2002)"

Result:
1° - "'John'"
2° - "'Adam'"

Instead I need:

Result:
"'John','Adam'"?

I have Win2000 Pro , SqlServer2000.

This is the best you can do:

SELECT
(SELECT username from tabl where year = 2001) AS [user_2001],
(SELECT username from tabl where year = 2002) AS [user_2002]
Jul 20 '05 #3
"Ross Presser" <rp******@imtek.com> wrote in message
news:m8***************@rpresser.invalid

This is the best you can do:

SELECT
(SELECT username from tabl where year = 2001) AS [user_2001],
(SELECT username from tabl where year = 2002) AS [user_2002]


Very cool !!
I think you must be a SqlServer creator ... ;-)))
Thank Everybody

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 20 '05 #4

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

Similar topics

3
by: Hendry Taylor | last post by:
I have a problem where if I issue a select * from against a database it returns no data, but if I select column from it returns the data. Why would the * not be working as a wildcard?
29
by: Mainlander | last post by:
An ISP I belong to uses Majordomo for their mailing list system. I'd like to encourage them to move to a system that uses a database, preferably psql which they already run on their server....
3
by: ezra epstein | last post by:
I'm been banging my head over this for a little while now. Here's a simple function to return a record: <code> CREATE OR REPLACE FUNCTION create_item_record_for_override(INTEGER, VARCHAR )...
10
by: Antanas | last post by:
The problem is that when AddID is used multiple times in the same select statement, it returns the same value in all places. How could I force function AddID to increment OBJECTID sequence? Here...
4
by: VK | last post by:
Hello, I have a dataset which has one datatable in it. The dt has over 3000 rows in it. Now I would like to get the rows where the StartDate is 15 Feb 2005, so I did the following: ...
1
by: paddymullaney | last post by:
Hi I have a query that is performing very strangely. I f I put a top statement in it returns rows, so Select top 10 * from .......
1
by: rosie2006 | last post by:
Environment: .net2.0 over oracle Problem? a simple select statement within a DetailsView that gets two parameter values from a GridView SelectedValue. It might be valuable to understand that to...
2
by: alok | last post by:
Hi I have opened a serial port and then blocked on a select system call . but select returns even if no data is comming from other end. So when I read the buffer after select returns, I only...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
2
by: msridhar87 | last post by:
hi, am doing a multi server chat program using select()..in the client side i need to multiplex thei/p from server and stdin. #include <stdio.h> #include <sys/types.h> #include <sys/socket.h>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.