Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUM on a field

Status
Not open for further replies.

PETEHO

Programmer
Joined
Jan 17, 2002
Messages
45
Location
GB
I want to sum journalamt but using the part field in the group by satement but it will only let me use the posting_code field

I know its probably simple but I don't write SQL


SELECT journal_number, Left(posting_code,2) as part, SUM(journal_amount) as journalamt
FROM [CS311].[scheme].[nltranm]
where (journal_number not like 'c3%' and journal_number not like 'cp%') and (journal_date = CAST(FLOOR(CAST(getdate()-1 AS FLOAT)) as DATETIME))
Group by journal_number,posting_code
order by journal_number,part
 
group by journal_number, Left(posting_code,2)

--------------------
Procrastinate Now!
 
I was just about to add the same, Group By journal_number, Left(posting_code,2)

Thanks
Adam

Adam Blackwell
Development Manager
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top