Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

display horizontally records

Posted on 2004-04-23
5
Medium Priority
?
734 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 100 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 100 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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