Question: I have a user table, the important columns are these.

```
id | logintime
---+-----------
1  | 2004-01-10
2  | 2006-02-10
3  | 2005-03-12
4  | 2006-10-23

```

I want to create a column that approximates time the user registered. To do this I want to take the lowest logintime on id and every id larger than itself. the logintime is the last time the id has logged into the site.

While it is not perfect, it gives a "latest possible date" for the registertime. Since id is autoincrement we know that the person with id 2 has registered before the person with id 3, so we approximate the registertime for id 2 with the logintime for id 3.

The result would be 

```
id | logintime  | Registertime
---+------------+-------------
1  | 2004-01-10 | 2004-01-10
2  | 2006-02-10 | 2005-03-12
3  | 2005-03-12 | 2005-03-12
4  | 2006-10-23 | 2006-10-23

```

Can I do this with one query? I think I can achieve it with a t-cursor, but that seems a bit too fancy for this, simple, task.

**Edit**: Clarified the question.

Answer: 
Still not one-liner, but something that can save you from explicitly maintaining parent method type:

```
declare let parentController: ParentComponentController;

class ChildComponentController {
    constructor(private parentMethod: typeof parentController.parentMethod) {}
}

```
The main purpose of [Generics and Generic Constraints](http://www.typescriptlang.org/docs/handbook/generics.html) is describing the relationship of types.

```
interface ICommonApi {
    parentMethod(param1: number, param2: string): boolean;
}

class ParentComponentController {
    public parentMethod(param1: number, param2: string): boolean {
        return param1 > 0 && param2.length > 2;
    }
}

class ChildComponentController<P extends ICommonApi> {
    constructor(private parent:P) { }

    public onCertainTrigger() {
        this.parent.parentMethod(10, 'something');
    }
}

let p = new ParentComponentController();
let c = new ChildComponentController(p);

```

If interface is simple:

```
class ParentComponentController {
    public parentMethod(param1: number, param2: string): boolean {
        return param1 > 0 && param2.length > 2;
    }
}

class ChildComponentController<P extends { parentMethod: (param1: number, param2: string) => boolean}> {
    constructor(private parent:P) { }

    public onCertainTrigger() {
        this.parent.parentMethod(10, 'something');
    }
}

let p = new ParentComponentController();
let c = new ChildComponentController(p);

```