Question: I have a table that looks like this -

```
ZIP DC1 DC2 DC3 Min Min(DC)
1   2   3   4   2   DC1
2   5   4   3   3   DC3

```

Basically, I want to populate the last column `Min(DC)`. That column should show respective DC of the `Min` column. I have been doing it with excel y using vlookp but since my data set has grown, I need to get this done in Teradata or any other sql based format.

Answer: 
Partitions are sub-directories. When correctly defined Athena can skip over sub-directories that do not contain relevant data.

For example, if a table is partitioned by date (YYYY-MM-DD), there would be a directory called `date=2017-11-08` that contains only data for that day.

Given that all your data is contained in a single CSV, you *cannot* use partitions. If you were to divide the file into individual daily files within an appropriate directory structure, Athena would run faster for you and would be cheaper to operate.

Athena cannot generate the partitions for you -- you must provide Athena with data that is already partitioned. The `ADD PARTITION` and `MSCK REPAIR TABLE` commands merely scan in and use the existing partitions.

See AWS Big Data blog: [Analyzing Data in S3 using Amazon Athena](https://aws.amazon.com/blogs/big-data/analyzing-data-in-s3-using-amazon-athena/)
One interesting point, folders in S3 are [not actually folders](https://serverfault.com/questions/435827/what-is-the-difference-between-buckets-and-folders-in-amazon-s3), I tend to think of them as tags. To John's point, you need to slice and dice your data and then tag it as such: 

```
s3://mybucket/mydata/date_partition=2017-01-01/customer_partition=12345/somdedata.csv

```

Certain applications such as the web UI and S3 browser present S3 "folders" as directories, but when you start making API calls you'll find they don't behave as such. 

One of the nice things about this structure is that Athena will treat all files with a certain "tag" (such as `date_partition=2017-01-01/customer_partition=12345/`) as being in the same partition. So, to Athena, these are equivalent:

```
s3://mystuff/data/date_partition=2017-01-01/customer_partition=12345/somehugefile.csv
s3://mystuff/data/date_partition=2017-01-01/customer_partition=12345/asmallerfile.csv
s3://mystuff/data/date_partition=2017-01-01/customer_partition=12345/anothersmallerfile.csv

```

Sometimes, splitting data like this can be really useful.