# base simple calculation queries

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 close merge delete

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

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

Sort by » oldest newest most voted

In HSQLDB 1.8 (the default embedded database):

 SELECT "Product ID", "Cost", "Cost" * .2 AS "VAT" FROM "Products"

more

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

more

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.

( 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.

( 2017-05-08 11:51:54 +0200 )edit