MySQL Forums
Forum List  »  InnoDB

Insert count and sum into two columns in same record
Posted by: Tony Darnell
Date: July 24, 2008 02:09PM

I have the following two queries:

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

SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'C' 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

Options: ReplyQuote


Subject
Views
Written By
Posted
Insert count and sum into two columns in same record
5101
July 24, 2008 02:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.