Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. The STATION table is described as follows:
Problem Difficulty Level : Hard
Data Structure
- ID
- City
- State
- Lattitude
- Longitude
Data for station table
Sample Input
For example, CITY has four entries: DEF, ABC, PQRS and WXY.
Sample Output
ABC 3
PQRS 4
In Spark we will solve this problem using two ways
- Using PySpark Functions
- Using Spark SQL
Use below notebook for solution
In Postgre SQL We will load data from CSV using PostgreSQL Import functionality. And then we will solve this problem.
Output Query
Please also follow below blog for understanding this problem
