Home » SQL & PL/SQL » SQL & PL/SQL » How to get a particular column (oracle 9i,win)
How to get a particular column [message #337771] Fri, 01 August 2008 02:30 Go to next message
koteshwar
Messages: 7
Registered: October 2006
Location: hyderabad
Junior Member
Hi ,

I have got a table having 30 columns as

sale_id,
Customer_id,
Cust_address,
-
-
-
-
-
-
-
-
- etc,

my criteria is to retrieve the column 5 and 20.I don't know the column names in that table.This should be done using an sql statement.
Re: How to get a particular column [message #337772 is a reply to message #337771] Fri, 01 August 2008 02:57 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
What have you tried?
Re: How to get a particular column [message #337773 is a reply to message #337771] Fri, 01 August 2008 02:58 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Check USER_TAB_COLUMNS; here's an example - modify it so that it suits your needs:
SQL> select column_id, column_name
  2  from user_tab_columns
  3  where table_name = 'EMP'
  4    and column_id in (3, 8);

 COLUMN_ID COLUMN_NAME
---------- ------------------------------
         3 JOB
         8 DEPTNO

SQL>
Re: How to get a particular column [message #337778 is a reply to message #337771] Fri, 01 August 2008 03:35 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
my criteria is to retrieve the column 5 and 20.

And what is the business need to this?
You must not care about column position in your code.
It's just a way to hell.

Regards
Michel

Re: How to get a particular column [message #337787 is a reply to message #337773] Fri, 01 August 2008 03:57 Go to previous messageGo to next message
koteshwar
Messages: 7
Registered: October 2006
Location: hyderabad
Junior Member
Thanks a lot for the help.
Re: How to get a particular column [message #337812 is a reply to message #337787] Fri, 01 August 2008 04:54 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Michel Cadot wrote on Fri, 01 August 2008 10:35

And what is the business need to this?

pablolee wrote on Fri, 01 August 2008 09:57
What have you tried?

koteshwar wrote on Fri, 01 August 2008 10:57
Thanks a lot for the help.


Whatever you do, ignore those questions.
Just imagine, people might actually give you good advise..
Re: How to get a particular column [message #337883 is a reply to message #337771] Fri, 01 August 2008 08:17 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
koteshwar wrote on Fri, 01 August 2008 03:30

I have got a table having 30 columns as

sale_id,
Customer_id,
Cust_address,
-
-
-
-
-
-
-
-
- etc,

my criteria is to retrieve the column 5 and 20.I don't know the column names in that table.This should be done using an sql statement.


Sounds like another person enrolled in the Monty Python School Of Nonsensical Requirements. A lot of people here seem to be in the same class.
Re: How to get a particular column [message #337912 is a reply to message #337771] Fri, 01 August 2008 09:46 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Just the start of a new school season. Homework, gotta love it.
Re: How to get a particular column [message #338027 is a reply to message #337912] Sat, 02 August 2008 10:06 Go to previous message
koteshwar
Messages: 7
Registered: October 2006
Location: hyderabad
Junior Member
Thanks
Previous Topic: if else syntax
Next Topic: COMPARISON OF CURRENT RECORD WITH PREVIOUS OR NEXT RECORD
Goto Forum:
  


Current Time: Sat Feb 15 15:00:55 CST 2025