Ask Your Question

Another SQL question [closed]

asked 2017-05-13 19:54:47 +0200

Avvy65 gravatar image

updated 2017-05-13 20:22:14 +0200

Ratslinger gravatar image

I am using HSGLDB database and what works in another database does not work in this new one. This works SELECT "Cost" * .2 AS "VAT1" FROM "tblRecInfo" But this doesn't: SELECT "NetCost" * .05 AS "VAT" FROM "tblEonEnergyPlan" In the SQL window from Tools, the output is just commas, and no figures.

The NetCost is to be calculated by the query, then the VAT figure added to it. I have found that if I use any other field ie Payment or UsageCharge, the VAT figure is calculated and shown. Also , if I enter a figure in the NetCost field, the VAT is calculated and shown. I must be missing something blindly obvious! Thanks for your patience.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-10-04 09:02:50.091320


If 'NetCost' is to be calculated by the query, where is that calculation?

Ratslinger gravatar imageRatslinger ( 2017-05-13 20:05:32 +0200 )edit

opps sorry forgot to add it: SELECT "UsageCharge" - "Reward" AS "NetCost" FROM "tblEonEnergyPlan"

Avvy65 gravatar imageAvvy65 ( 2017-05-13 20:10:12 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-05-13 20:20:34 +0200

Ratslinger gravatar image

Again, learning SQL is very important in using ANY database. This is pretty simple and almost identical to the last problem. To get a result of both calculations use this statement (un-tested):

SELECT "UsageCharge" - "Reward" as "NetCost", ("UsageCharge" - "Reward") * .05 AS "VAT" FROM "tblEonEnergyPlan"

If this answers your question please click on the ✔ (upper left area of answer).

edit flag offensive delete link more


Yes, I need to get out of Access mode and into SQL. I'm afraid it's going to be one step at a time. Thank you, it did work.

Avvy65 gravatar imageAvvy65 ( 2017-05-13 20:44:01 +0200 )edit

You're quite welcome. SQL is there in Access too, but in a different way. When I first started with Base I soon discovered SQL was critical so I learned as I was learning Base. Here is a site which may help - click here.

Ratslinger gravatar imageRatslinger ( 2017-05-13 20:51:27 +0200 )edit

Just to let you know, I have managed to get all 4 of my databases from Access to LO Base, and have spent time with pen and paper working out by steps on how to get the sql statements working. Thak you anyways for your time and patience with me.

Avvy65 gravatar imageAvvy65 ( 2017-05-14 21:24:18 +0200 )edit

@Avvy65 Again, you are welcome. Can't say it was always easy to get some of the concepts across, but I am certainly glad you have the desired results.

Ratslinger gravatar imageRatslinger ( 2017-05-14 21:28:48 +0200 )edit

Question Tools

1 follower


Asked: 2017-05-13 19:54:47 +0200

Seen: 49 times

Last updated: May 13 '17