Ask Your Question
0

base simple calculation queries

asked 2017-05-07 20:11:00 +0200

Avvy65 gravatar image

updated 2017-05-08 11:36:14 +0200

I have a couple of Access databases which have caculation queries, and I am finding that it is not that simple in base. For example, I want to calculate the vat amount on an item price, so I tried this: VAT AS "'Cost' *0.2" , but it doesn't work. Cost is say £29.95, so what is the vat payment of 20 percent.

I have looked at the HSQL manual for this and it only describes more complex queries with multiple fields, and I have tried similar SQL code but for my needs to no joy.

@librebel, I did try that earlier and it gave me a syntax error.

@EasyTrieve, thank you that has done the job for me. Yes, the manual is good if you know where to look.

edit retag flag offensive close merge delete

Comments

hello Avvy65, assuming that "Cost" is a field in your table you could try: "Cost" * 0.2 AS VAT

librebel gravatar imagelibrebel ( 2017-05-07 20:20:59 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2017-05-07 21:48:42 +0200

EasyTrieve gravatar image

In HSQLDB 1.8 (the default embedded database):

 SELECT "Product ID", "Cost", "Cost" * .2 AS "VAT" FROM "Products"
edit flag offensive delete link more
0

answered 2017-05-07 21:18:52 +0200

Avvy65 gravatar image

Thanks but I am getting syntax errors with using that in SQL, and yes "Cost" is a field .

edit flag offensive delete link more

Comments

Hi @Avvy65, thanks for the question. Please put your comments and updates in your original question by editing it, or in other attached comments, but not in an answer box as you have done here. The idea is that others can search for your same question and possibly find answers. If they find more questions as answers that doesn't help anyone. K? Thanks.

EasyTrieve gravatar imageEasyTrieve ( 2017-05-07 21:56:20 +0200 )edit

What is the syntax error? Your VAT AS "'Cost' *0.2" should be "Cost" * 0.2 AS "VAT" - wrong order and punctuation. The sample from @EasyTrieve works for me.

peterwt gravatar imagepeterwt ( 2017-05-08 11:51:54 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-07 20:11:00 +0200

Seen: 203 times

Last updated: May 08 '17