Solved

display horizontally records

Posted on 2004-04-23
5
729 Views
Last Modified: 2007-12-19
i have only one coloumn in a table i want to dispaly all the datas in a row.Name of the table is student which contains only one coloumns slno
Student
           Slno
           1
           2
           3
           4
           5
I want to display them as
slno 1 2 3 4 5
0
Comment
Question by:babita220004
[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
5 Comments
 
LVL 6

Accepted Solution

by:
nathaniel earned 25 total points
ID: 10898331
in Access SQL, you may try

TRANSFORM Last(Student)
SELECT "Slno" AS Names
From Student
GROUP BY ""
PIVOT Sino;


0
 
LVL 1

Expert Comment

by:Djuradj
ID: 10898461
Display it where? On your web page, gui application,...?
Which server-side language (Script) do you use? Which DB do you use?

If you want to crete a query which will collect values of this one column (Slno) and sore it in one single row, it is only to possible to by creating temporary table with as many columns as you query returns rows. And then, to create (build) a query to insert those values into that temp table.
OR to user pivot table. You could use an OLAP (OnLine Analytical Processing) data cube to get PIVOT functionality. "Pivoting" will be supported in Yukon (next version of ms sql server), and  i am not sure about Oracle.

Anyway, to hard task, so If you can skip to do that on sql server - don't do it.
0
 
LVL 8

Assisted Solution

by:baonguyen1
baonguyen1 earned 25 total points
ID: 10898613
In Oracle if you know the maximum number of rows you can use:

SQL> select id from t1;

        ID
----------
         1
         2
         3
         4
         7
         5
         6

7 rows selected.

SQL> ed
Wrote file afiedt.buf

  1  select rtrim(
  2  max( decode( rownum, 1, id, null) ) ||','||
  3  max( decode( rownum, 2, id, null ) ) ||','||
  4  max( decode( rownum, 3, id, null ) ) ||','||
  5  max( decode( rownum, 4, id, null ) ) ||','||
  6  max( decode( rownum, 5, id, null ) ) ||','||
  7  max( decode( rownum, 6, id, null ) ) ||','||
  8  max( decode( rownum, 7, id, null ) ), ',' )
  9* from t1
SQL> /

--------------------------------------------------------------------------------
1,2,3,4,7,5,6

Or if you dont know the max of rows you can use pl/sql

SQL> ed
Wrote file afiedt.buf

  1  create or replace function column_row return varchar2
  2    is
  3        v_data varchar2(4000);
  4    begin
  5            for x in ( select id from t1 )
  6            loop
  7                    v_data := v_data || ',' || x.id;
  8            end loop;
  9            return ltrim(v_data, ',' );
 10*   end;
SQL> /

Function created.

SQL> select column_row from dual;

COLUMN_ROW
--------------------------------------------------------------------------------
1,2,3,4,7,5,6

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 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