Answer the question
In order to leave comments, you need to log in
How to search in SQL database by groups?
Hello!
There is a SQL database with the following structure:
Alloy grades are stored in the database. Each brand has a list of chem. elements, as well as the minimum and maximum content of these elements in this brand.
Further introductory: there are results by elements, for example:
Ag - 0.007
B - 0.002
Fe - 0.06
Cu - 0.01
How to create a search for brands in the database to determine which brand they correspond to?
There is no Mg in the input, but we must nevertheless receive an answer - Entry No. 2.
Answer the question
In order to leave comments, you need to log in
select
name
from table
where
(element = "Ag" and Min <= 0.007 and 0.007 <= Max)
OR
(element = "B" and Min <= 0.002 and 0.002 <= Max)
OR
(element = "Fe" and Min <= 0.06 and 0.06 <= Max)
OR
(element = "Mg" and Min <= 0.025 and 0.025 <= Max)
OR
(element = "Cu" and Min <= 0.01 and 0.01 <= Max)
group by Name
having count(ID) = 5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question