Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Combine two select statements in one SQL statements

651845Jul 24 2008 — edited Jul 25 2008
I have the following two queries that I need to combine into one query, where it updates a single row at the same time.

SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = "4837"

SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = "4837"

I want to insert the values of each select statement into two columns of the same row, as well as insert the account number from the select statement.

After the query has been executed, the database row will look like this:

ACCOUNT COUNT SUM
4837 354 1039202

I am looking for suggestions on how to:

- either combine the two into one query
- simply update each column with the value from each query by updating the row with the account value

I am a SQL newbie - so I appreciate any assistance.

Thanks,

Tony
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2008
Added on Jul 24 2008
7 comments
15,354 views