Now, let's list all the items from both the automobiles
and motorcycles
table. Because we have a long list of items, to save page space we will limit the output to only the top five items, as follows:
[Hadoop.testdomain:21000] > select * from automobiles limit 5; Query finished, fetching results ... +-----------+------------+----------+----------+------------+--------+----------+-----------+------------+--------------+--------+ | make | model | autoyear | fueltype | numofdoors | design | autotype | cylinders | horsepower | city_hwy_mpg | price | +-----------+------------+----------+----------+------------+--------+----------+-----------+------------+--------------+--------+ | Audi | A4 | 2011 | gas | 4 | sedan | casual | 6 | 476 | 22-30 | 45000 | | Jeep | Compass | 2007 | gas | 3 | suv | sport | 6 | 170 | 24-32 | 22000 | | Dodge | Challenger | 2013 | gas | 4 | coupe | casual | 6 | 210 | 20-30 | 28000 | | Chevrolet | Volt | 2014 | electric | 4 | sedan | casual | 0 | 180 | 35-40 | 35000 | | Toyota | Prius | 2013 | hybrid | 4 | sedan | casual | 4 | 134 | 51-48 | 32000 | +-----------+------------+----------+----------+------------+--------+----------+-----------+------------+--------------+--------+ Returned 5 row(s) in 1.77s
In the next step, we will use the same select
statement with a variation to list only those motorcycles that have autoyear
above 2010, as shown in the following code snippet:
[Hadoop.testdomain:21000] > select * from motorcycles where year > 2010; Query finished, fetching results ... +---------+---------------+------+----------+--------+--------+--------+--------+-----------+-----------+-------+ | make | model | year | fueltype | wheels | body | style | cc_rpm | highspeed | automatic | price | +---------+---------------+------+----------+--------+--------+--------+--------+-----------+-----------+-------+ | Harley | Tri Glide | 2012 | gas | 3 | deluxe | luxury | 1600 | 180 | false | 35000 | | Harley | Iron | 2012 | gas | NULL | luxury | 1500 | 200 | NULL | NULL | NULL | | Bramo | Icon | 2012 | electric | 2 | casual | sport | 4500 | 80 | false | 20000 | | Zero | Police | 2013 | electric | 2 | casual | sport | 4300 | 95 | false | 25000 | | Can-am | spider | 2014 | gas | 3 | deluxe | luxury | 998 | 120 | false | 22000 | +---------+---------------+------+----------+--------+--------+--------+--------+-----------+-----------+-------+ Returned 5 row(s) in 0.61s
Now, we will try to get a list of unique automakers from both the automobiles
and motorcycles
tables by using the distinct
command as follows:
[Hadoop.testdomain:21000] > select distinct(make) from automobiles; Query finished, fetching results ... +-----------+ | make | +-----------+ | Mercedes | | Audi | | Nissan | | Dodge | | BMW | | Toyota | | Fisker | | Honda | | Chevrolet | | Jeep | +-----------+ Returned 10 row(s) in 0.68s
And for the motorcycles
table, we will use the distinct
command as follows:
[Hadoop.testdomain:21000] > select distinct(make) from motorcycles; Query finished, fetching results ... +---------+ | make | +---------+ | Can-am | | Suzuki | | BMW | | Zero | | KTM | | Bramo | | Honda | | Triumph | | Ducati | | Harley | +---------+ Returned 10 row(s) in 0.48s
3.147.89.30