How to find amount exclusive of tax from an amount inclusive of tax? [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How to find amount exclusive of tax from an amount inclusive of tax?
Currently I'm using this query and getting the desired result.
I am searching for a simple query.
My current query:
select #amountExclusiveOfTax=
(#amountInclusiveOfTax) -
((#amountInclusiveOfTax) - (((#amountInclusiveOfTax)/#taxPercent+100) * 100))
Is there any easier way?

This was taught in day one of my business math class:
SELECT #amountExclusiveOfTax = #amountInclusiveOfTax / (1 + #taxPercetange / 100)
This assume your #taxPercentage is stored in percentage form. For example, if the tax is 15%, then #taxPercentage = 15. Another popular form is the decimal form, where it's stored as 0.15.

Related

How can I limit some specific numbers and return them with a title? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I have a table in postgresql which contains scores of students and I wanna show scores less than 10 with word 'failed' and more than 10 with the word 'passed'. How can I do that using a query?
As result I want a table with two columns. First scores and second 'passed' or 'failed'.

Count without duplicates [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I'd like to count column values without any duplicates.
In the given example, I'd expect the SQL query to sum up column a to 6 (every value counted once)
How about
select count(distinct a)
from table

Need RegEx to filter dataset according to specific position in string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Want to filter dataset with SQL query using RegEx to filter entries based on the time (hour) e.g. 19:XX or 09:XX. The hour part of the string would be in position 12 and 13.
Checked a few other questions and articles, but I'm very new to this and can't figure it out. Don't know which SQL database it is, but I work with it on Google BigQuery.Thanks for your help!
Screenshot of data entries
The standard way to access the hour in a date/time is:
where extract(hour from timecol) = 19
Not all databases support extract. All should have something similar.

access multiple my sql database at a time? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
how can i access multiple my sql database at time, what is the mechanism behind it?????
eg: i have three different database that contain product(shoes) along with price and there description etc...
so whenever the user type shoes and set its price ... my search bar should be able to retrieve the data in respect of price.. from multiple database..
You can use like
Select * FROM database1.products WHERE field = ?
UNION ALL
SELECT * FROM database2.products field = ?
UNION ALL
SELECT * FROM database3.products field = ?

Optimization of for loop in oracle [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I was asked on my apprenticeship following question:
Why query like:
FOR i in ( SELECT * FROM TABELKA) LOOP
is not efficient? How to change it to make it more efficient?
There is no further information added.
Collect, all data at once, into a collection. Boom! One query and you have it all without looping.
SELECT *
BULK COLLECT INTO a_collection_type_variable
FROM a_table;