Home » SQL & PL/SQL » SQL & PL/SQL » Result of COUNT function back in Table Column (Oracle 9i)
Result of COUNT function back in Table Column [message #396192] Sat, 04 April 2009 17:06 Go to next message
remi58
Messages: 2
Registered: April 2009
Junior Member
Hello,

I am new at this forum and a beginner with sql. I would like to know how you can update a table column with the result of a COUNT.

I think I need the following code but do not know how to get the count result

First count the rows:
Select count(id) from emp
Where id='John'

Result will be:
COUNT(ID)
------------
2

bring result into table:

update emp
set members = "result of the count"
where id='John'

Hopefully one of you can help me with this.

Kind regards and thank you in advance

Rene
Re: Result of COUNT function back in Table Column [message #396193 is a reply to message #396192] Sat, 04 April 2009 17:23 Go to previous messageGo to next message
BlackSwan
Messages: 25036
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Please, please, please Read & Follow Posting Guidelines above.
Go to the section labeled "Practice" & do as directed.


Post DDL for tables.
Post DML for test data.

Post expected/desired results.

> (Oracle 9i)
Why starting with obsolete & unsupported version?

[Updated on: Sat, 04 April 2009 17:38]

Report message to a moderator

Re: Result of COUNT function back in Table Column [message #396208 is a reply to message #396192] Sun, 05 April 2009 00:06 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You can directly update with the result of a select.
Have a look at SQL Reference: UPDATE.

Regards
Michel
Re: Result of COUNT function back in Table Column [message #396701 is a reply to message #396193] Tue, 07 April 2009 14:39 Go to previous message
remi58
Messages: 2
Registered: April 2009
Junior Member
Hello Michel and BlackSwan,

Thank you both for your replay and point me in the good direction. Sorry I did my posting not as it should be. Will do better next time.

Regards

Rene
Previous Topic: Query recent records
Next Topic: null values
Goto Forum:
  


Current Time: Sun Dec 04 12:28:05 CST 2016

Total time taken to generate the page: 0.04788 seconds