Actually some guy responded to you, and came up with some case statement in t-sql.
But I'm more curious about this table structure you have.
Let me know what the surrounding objects/table/situation is, but here's my thoughts just on what I saw in your post:
Summing items horizontally is difficult to do normally (since you need to check if this column equals this and that column equals that, etc.) Assuming there is some invoice being taxed, let me give you another option of design:
object:Invoice
--------------
InvoiceID int
(insert other
invoice stuff
here)
Association object: Invoice_Tax
---------------
TokenRowID
InvoiceID
TaxID
TaxAmount
ok, follow me here:
Lets say the invoice can have multiple taxes applied to it (and GST can come in twice...btw, i didn't know you were Canadian!) GST would be in the taxes table as
TaxID = 1
TaxName = 'GST'
TaxPercent = .07
Now lets say there are two instances of gst for Invoice 1.
In the association table (keep in mind that this scenario assumes the methodology of mapping classes to tables), there would be these two records:
RowID = 1
InvoiceID = 1
TaxID = 1
Amount = 50.00
RowID = 2
InvoiceID = 1
TaxID = 1
Amount = 50.00
So what does this get us? Well, now that we have it all normalized, running a query to find the total of any given tax is simple:
Select Sum(Amount) From Invoice_Tax Where InvoiceID = 1
And TaxID = 1
Let me know what you think, and if I'm way off on how your app is supposed to work.
You bet I am Canadian Jack!
I live in Edmonton at the moment. Been here for a year now. Pretty nice city I like it.
Not sure if your solution would entirely work, prolly would if I bent it a little the brain is a little fuzzy today.
I think it might it is just that my system is capable of hosting multiple vendors - shall we call them - on it.
Umm... thinking ... OH yes here we go.
In the specs that I was given the invoice/charges need to be a snap shot. In case some bozo changes the taxes all about the charge needs to stay the same. AKA the govt decides to lower/raise the tax rate or something silly.
On a side note all lot of our customers are Americans.
Hmm I definetly see your solution working. In fact the more I look at it the more I like it. However, the system is close to completion and I don't want to make db structure changes. It would set me back a couple of days on my schedule. Basically I am making a report that has been requested. Total of Taxes over a time period.
Thanks for the help though. I'll let you know how it goes. That'l do donkey, that'l do
Mark
It did work other Mark. But look at the stuff that I ended up with HOLY MONKEY NOODLES it is so simple.
Thanks for posting though.
Jack: I was in Lloydminster before this, but came to Edmonton to go for some more school. I took the NAIT BAIST program (Bachelor of Applied Information Systems Technology) majoring in IS. Where are you from? I think you said somewhere but I have forgotten. That'l do donkey, that'l do
Mark
Oh right, I remember hearing about Lloydminster when I lived in Saskatoon (way back in the day, like grades 1 - 3).
Rough Riders. BAH! Another lucky labour day for the rough riders!
So how does that work for the town being on the border? I mean, everything in alberta would have less tax, right (only gst), so wouldn't everyone just shop there?
Can't remember anymore if the whole city is exempt or not. However if you live on the Saskatchewan side you get the healt care and most importantly the car insurance. Mwahahaha I was paying $42 a month for car insurance there.
I do know alot of the .. or most of the stores are located on the albertan side. That'l do donkey, that'l do
Mark
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.