Home » SQL & PL/SQL » SQL & PL/SQL » Oracle
Oracle [message #305202] Mon, 10 March 2008 02:31 Go to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Hi all I have 1000 records in a table . i want to d\ivide the records as 1st 200 rows column name as x1,2nd column name as x2 for other 200 rows.. How to write a query for this ..
please let me know.

i.e I have table 'X' it contains 1000 recs.i want ot divide as

X1
--
200 records

x2
--
200 records

X3
---
200 records....like this

if i am giving select * from emp where rowcount<201 I am getting the following error
" ERROR at line 1:
ORA-00904: "ROWCOUNT": invalid identifier"
Thank you.

[Updated on: Mon, 10 March 2008 02:40]

Report message to a moderator

Re: Oracle [message #305206 is a reply to message #305202] Mon, 10 March 2008 02:51 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
ROWCOUNT is a cursor attribute ,so you are getting the error.And what exactly are you trying to do?


regards,
Re: Oracle [message #305212 is a reply to message #305202] Mon, 10 March 2008 03:15 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
NTILE

Regards
Michel
Re: Oracle [message #305220 is a reply to message #305206] Mon, 10 March 2008 03:22 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Hi I have 100o records in a table. table name is X
X
--
1
2
3
....
1000

Now i want to divide these recs as
X1
--
1
2
3
...
200

X2
---
201
202
203
...
400

X3
--
401
402
...
600
Like this I want to divide these records.
So please give the solution for this.
Thank you,
Re: Oracle [message #305224 is a reply to message #305220] Mon, 10 March 2008 03:26 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Same answer.

Regards
Michel
Re: Oracle [message #305225 is a reply to message #305224] Mon, 10 March 2008 03:30 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Michel,

I didn't get the required answer...

Please tell me how to use the query using NTILE.

I have columns : dname,deptno . Using this I want to divide the rows..Please give me the solution for this..

Thank you.
Re: Oracle [message #305234 is a reply to message #305202] Mon, 10 March 2008 03:47 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
The example in that link seems clear. If you do not know, how to use it in single SQL statement, have a look at Multitable Insert; especially its Examples (I recommend you the last ones).
Alternatively you may use ROWNUM (in case you know the total number of table rows).
Re: Oracle [message #305242 is a reply to message #305234] Mon, 10 March 2008 04:11 Go to previous message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

Hi All,

Thank you very much...
Previous Topic: Exponential values in oracle.
Next Topic: sql query
Goto Forum:
  


Current Time: Mon Dec 05 12:40:49 CST 2016

Total time taken to generate the page: 0.05437 seconds