This is the database.
Write a SQL construct for the following query: Print measure number, tree number and type of measure from the measure table. Order output by measure data.
SELECT Me_numb,Me_trnumb,Me_type
FROM Measure
ORDER BY Me_data ASC;
Write a SQL construct for the following query: Print a unique list of measure types.
SELECT DISTINCT Me_type
FROM Measure;
Write a SQL construct for the following query: Print the minimum and maximum values of measure whose type is 'ACID'.
SELECT MIN(Me_result),MAX(Me_result)
FROM Measure
WHERE Me_type =’ACID’ ;
Write a SQL construct for the following query: List the forest name,company name and location for any forest whose name must start with 'GREAT', and has a size greater than 1000000 or its location is 'SOUTH'. In the output ensure that company name and location are concatenated as 'ABC Co Ltd- SOUTH'.
SELECT Fo_name,Fo_comp,Fo_Loc
FROM Forest
WHERE ((Fo_name LIKE ‘GREAT%’ AND Fo_size > 1000000) OR (Fo_location =’SOUTH’));
Write a SQL construct for the following query: List species name, species wood type, forest name and forest location for all trees. Ensure that output doesn't contain repetitions.
SELECT Sp_name ,Sp_woodtype
FROM Species
UNION
SELECT Fo_name,Fo_location
FROM Forest;
Write a SQL construct for the following query: In the measure table one can find rows for 'HEIGHT' reading for many trees. List those trees that have a measured height (ie: me_type='HEIGHT') that is actually greater than the expected height of the tree's species max height (ie:sp_maxht).
SELECT Sp_maxht
FROM Species
UNION
SELECT Me_trnumb,Me_result
FROM Measure
WHERE Me_result >Sp_maxht
Write a SQL construct for the following query: List trees that are co-located (ie: tr_loc values are identical) and where one tree is the 'granddaughter' of the other. The output should include the number of each tree, their common location and forest name.
SELECT Tr_numb,Tr_loc,Tr_parent
FROM Tree
WHERE ( I have no idea how to continue this questions...)
Write a SQL construct for the following query: For each species with the same wood type (ie: sp_woodtype) compare their maximum height ( ie:sp_maxht). The output should include the species wood type, species name of the larger height, species of the smaller height.
SELECT Sp_woodtype,Sp_maxht
FROM Species
WHERE Sp_woodtype = Sp_woodtype
Write a SQL construct for the following query: For each species wood type, forest location and measure type output the average of measure result and count of aggregates. Exclude measure on species whose wood type is 'SOFT' and whose aggregate count is less than 10.
Write a SQL construct for the following query: Which trees have all measure types?
In the last 4 questions can you give me a couple of hints so I can try to worth them out alone ?
Thanks a lot.