[Solved] Sum total of column in database

Discuss the database features
Post Reply
MikeG123
Posts: 8
Joined: Sat Aug 16, 2014 11:32 am

[Solved] Sum total of column in database

Post by MikeG123 »

This must be a simple query, but after reading through many posts on the topic I can't get it to work.
I have a table called payslips with columns including payslip_id, tax and net_pay. I want to calculate the totals for tax and net pay. I select sum in the function box for the tax field but running the query gives me SUM("tax") 0.
Please help?
Last edited by Hagar Delest on Mon Feb 27, 2017 2:47 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4 Windows 8
User avatar
charlie.it
Volunteer
Posts: 417
Joined: Wed Aug 21, 2013 2:12 pm
Location: Italy

Re: Sum total of column in database

Post by charlie.it »

Ciao, please compare your database with mine.
Attachments
Test.odb
(4.79 KiB) Downloaded 374 times
charlie
Italian AOO Admin
macOS 14 Sonoma M1: Open Office 4.1.15 - LibreOffice 7.5.7.1

http://www.charlieopenoffice.altervista.org
MikeG123
Posts: 8
Joined: Sat Aug 16, 2014 11:32 am

Re: Sum total of column in database

Post by MikeG123 »

Thank you Charlie, your help is much appreciated. You make it look so simple, which I'm sure it should be. I set up a database like yours, ran a sum query and got the results as shown on the screenshots attached. Can you make sense of it?
Mike
Attachments
Screenshot (2).png
Screenshot (3).png
Test.odb
(3.17 KiB) Downloaded 142 times
OpenOffice 4 Windows 8
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Sum total of column in database

Post by robleyd »

The difference is that charlie.it has used decimal fields (numeric) whereas you have used text fields (string).
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
MikeG123
Posts: 8
Joined: Sat Aug 16, 2014 11:32 am

Re: Sum total of column in database

Post by MikeG123 »

Hooray, that was it!
Thank you David and Charlie.it.
OpenOffice 4 Windows 8
Post Reply