SUM fields in SQL server depending on another field and using inner join -
The title may be slightly vague, but let me explain:
I have a script that makes Create a database and two tables, one transaction and one for account:
create table transactions (transactionID VARCHAR (10), description VARCHAR (70), account id VARCHAR (5) , Create Zero Zodiac Contract Contract Transaction PK Primary Key (TransactionIID) Table Account (Account ID VARARAR (10), Accountant VARCHAR (70) No, Bank VARCHAR (70) No, Tap Primary Account (Account ID) of contract accounts)
I want to write a selection statement for a list of all fields in the account table, with a total collection. I thought I could use INNER JOIN to display only each account, but I'm not sure that DISTINCT will work better.
Its purpose is for all transactions for each account, and that amount is the line for the account.
I can get the product to list the amount of each transaction, but not SUM of all types of transactions for each account.
Selection accounts .accountID, Accounts.accountName, Accounts.bank, Transactions.am account, join the transaction on account INNER account. AccountID = Transactions.accountID
Any help would be greatly appreciated.
You just need a () function:
SELECT a Include .accountID, a AccountName, a.bank, SUM (TMM) account in an account at IN.ER. AaccountID = t.accountID Group a.accountID, a.accountName, a.bank
When you are finished, you need to group with account ID. It will effectively add each group (each account).
Here are some SQL for you.
Comments
Post a Comment