My Table Looks Like this (Grouped based on GrandParent, Parent and Child)
Child | Parent | GrandParent | Date
2 | 1 | 1 | 2015-11-04 01:30:22 3 | 1 | 1 | 2015-11-05 01:30:22 4 | 4 | 4 | 2015-11-04 01:31:41 5 | 5 | 5 | 2015-11-04 01:31:41 7 | 7 | 7 | 2014-08-19 03:45:01 88 | 8 | 8 | 2014-08-19 03:45:01 90 | 8 | 8 | 2014-08-19 03:45:01 97 | 8 | 8 | 2015-03-18 03:45:01 704 | 8 | 8 | 2015-03-18 03:45:01 27 | 11 | 9 | 2015-10-22 06:42:30 28 | 11 | 9 | 2015-10-24 06:42:30 30 | 12 | 9 | 2015-11-15 06:42:30 31 | 12 | 9 | 2015-11-65 06:42:30
ie) Child without Parent will consider itself as Parent and GrandParent.
My Target is to order the above table such that 1) GrandParent Group with recent date should be at top 2) Inside GrandParent, Parent Group with recent date should be at top
3) Inside Parent, Child with recent date should be at top
The result should be:
Child | Parent | GrandParent | Date
31 | 12 | 9 | 2015-11-16 06:42:30 30 | 12 | 9 | 2015-11-15 06:42:30 28 | 11 | 9 | 2015-10-24 06:42:30 27 | 11 | 9 | 2015-10-22 06:42:30
3 | 1 | 1 | 2015-11-05 01:30:22 2 | 1 | 1 | 2015-11-04 01:30:22 4 | 4 | 4 | 2015-11-04 01:31:41 5 | 5 | 5 | 2015-11-04 01:31:41 7 | 7 | 7 | 2014-08-19 03:45:01 97 | 8 | 8 | 2015-03-18 03:45:01 704 | 8 | 8 | 2015-03-18 03:45:01 88 | 8 | 8 | 2014-08-19 03:45:01 90 | 8 | 8 | 2014-08-19 03:45:01
Thanks in Advance .
Aucun commentaire:
Enregistrer un commentaire