Question: In my onCreate method i have the following line of code.

```
CalendarView calendar = (CalendarView) findViewById(R.id.cal);

```

I'm trying to get the current selected date from this CalendarView and convert it to a String but in the method im using to do this calendar.getDate(); is causing an error.

Answer: 
If you do a query like this on `Familyname`. Output will be like this:

```
1-Kovács Albert
1-Kovács Dávid
1-Nagy Balázs

```

With this query:

```
SELECT
  RANK() OVER(PARTITION BY FamilyName ORDER BY FamilyName) AS iRank,
  Surename,
  FamilyName
FROM
  Table1

```

If you do the `RANK` on `SureName` and `order by FamilyName`. The output will be like this:

```
1-Kovács Albert
2-Kovács Dávid
1-Nagy Balázs

```

With this query:

```
SELECT
  RANK() OVER(PARTITION BY Surename ORDER BY FamilyName) AS iRank,
  Surename,
  FamilyName
FROM
  Table1

```
It depends entirely on what you want. To get either of your proposed results your analytic clause would have to be `rank() over ( order by surname )`. This query provides you with the `rank` of every record in the order of their `surname` ascending. As you have two people with the same surname then the order of those two people should *theoretically* be random. This is because `rank()` does not actually do any ordering of the result-set, you need an `order by` clause to do this; or at least to guarantee the results you want.

Something like:

```
select rank() over ( order by surname asc, familyname asc ) as rnk
     , surname, familyname
  from my_table
 order by rank() over ( order by surname asc, familyname asc ) 

```

This query returns the surname, family name and rank in order of ascending surname and family name. The result-set is ordered by the rank, meaning that it would look like this:

```
1 | Kovács | Albert
2 | Kovács | Dávid
3 | Nagy   | Balázs

```

This is the benefit and the problem with analytic functions, you can be massively specific in what you wish to do but if you want a specific answer you have to be exact in the query that you run.

The [documentation](http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions141.htm#SQLRF00690) provides another example using the `partition by` clause. If we were to apply this to your query, partitioning by `surname` and ordering by `familyname` your query and result set could look like this. 

```
select rank() over ( partition by surname order by familyname asc ) as rnk
     , surname, familyname
  from my_table

```

```
2 | Kovács | Dávid
1 | Kovács | Albert
1 | Nagy   | Balázs

```

This means that we rank all the familynames for each surname individually. As Dávid is after Albert he get's a rank of 2 in the surname Kovács. Note that with no specific `order by` there's no requirement for the result-set to be ordered.