Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
summing totals question
Old 01-02-2010, 12:17 PM summing totals question
Skilled Talker

Posts: 83
Trades: 0
Hello,

I have a table with invoice-totals. Each record is an invoice. Aside from the total, i also have the VAT number listed, as well as 'service' or 'goods' to indicate if its an invoicing of a service or of goods that were sold.

Now what i need is to sum all totals per VAT number, however i need this separate for 'service' and for 'goods'. So if a particular customer bought goods and services, then i will need 2 totals.

Maybe it's the champagne, but i can't figure out how to do this... LOL.

Any help?

Thanks and Happy New Year!

Matt

Last edited by killerwhale65; 01-02-2010 at 12:19 PM..
killerwhale65 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-02-2010, 12:27 PM Re: summing totals question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Something like:
Code:
SELECT fieldlist, SUM(vat_column) AS vat FROM table where type='service' GROUP BY vat_no;
UNION
SELECT fieldlist, SUM(vat_column) AS vat FROM table where type='goods' GROUP BY vat_no;
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-03-2010, 07:37 AM Re: summing totals question
Skilled Talker

Posts: 83
Trades: 0
ok thanks i will try this.
killerwhale65 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to summing totals question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14826 seconds with 12 queries