2

This is the date column from where I am trying to get average interval from top to bottom. For example First interval would be different between '2008-03-29' and '2009-04-04' and next interval would be the difference between '2009-04-04' and '2010-05-18' in days and list goes on. Click here to see the date list

Here is the part of stored procedure I have written.

SELECT Cow_ID, Cow_Age, Cow_Breed, count(animal_id) as Numb_calves_born, count(Calf_ID) as numb_calves_weaned, calve_interval, Cow_Sire_Breed  FROM(
    SELECT 
        @cow_id:=cattle_info_tbl.dam_ID as Cow_ID,
        cattle_info_tbl.cow_age as Cow_Age,
        @cow_breed:=(select breed from cattle_info_tbl where animal_id=@cow_id) as Cow_Breed,
        animal_id IN (select animal_id from cattle_info_tbl where dam_id=@cow_id) as animal_id,
        #cattle_info_tbl.animal_id as Calf_ID,
        @cow_sire_id:=(select sire_id from cattle_info_tbl where animal_id=@cow_id) as Cow_Sire_Breed,
        #Where goes the problem
        (MAX(cattle_info_tbl.birth_date)-MIN(cattle_info_tbl.birth_date)/(SUM(CASE WHEN weaning_tbl.manage_code='T' Then 0.5 ELSE 1 END))) as calve_interval


    FROM cattle_info_tbl 
    INNER JOIN measurement_tbl ON (cattle_info_tbl.chaps_id = measurement_tbl.chaps_id) AND entry_type='W'
    INNER JOIN weaning_tbl ON weaning_tbl.chaps_id=cattle_info_tbl.chaps_id
    where cattle_info_tbl.herd_id = input_herd_id AND dam_id!='' AND manage_code=0
    order by dam_id
Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
naqib83
  • 128
  • 3
  • 14
  • Might want to remove sql-server from the tag list as this looks like mysql specific – Xedni Sep 21 '17 at 21:10
  • See https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry Sep 21 '17 at 21:58
  • Do not use images of data it's such a waste of effort. Just provide sample data a text or as inserts or setup a http://sqlfiddle.com (i.e. don't expect others to prepare sample data for you). What makes '2008-03-29' the first row and what makes '2009-04-04'? Is it ascending order of the date that determines this? – Paul Maxwell Sep 22 '17 at 00:39
  • thanks for the input. – naqib83 Sep 22 '17 at 04:12

3 Answers3

1

nb: It is easier to add another answer than to edit the former.

  1. You need to use JOINED "derived tables" instead of "correlated subqueries". You will find this far more efficient too. Here you need to average some values so the derived table involves a group by.

  2. To use the technique where a previous value is carried over to the next row, you must cross join some variables, don't comment this out.

  3. The order by clause is vital to this technique. Here you must use a combined order involving dam_id as well as birth_date otherwise you would get a rubbish result.

Hopefully these queries will identify the logic for you. The first helps display the detailed logic of each row. The second displays the "derived table" before it is joined, and the third displays the effect of joining the derived table to the source (detail) table.

Query 1:

SELECT
      IF((t2.dam_id=@prev_dam), datediff(t2.birth_date,@prev_value), NULL) difference
    , @prev_dam
    , @prev_value
    , t2.dam_id
    , t2.birth_date
    , @prev_dam := t2.dam_id
    , @prev_value := t2.birth_date
FROM cattle_info_tbl t2
CROSS JOIN (SELECT @prev_dam:=null x, @prev_value:=str_to_date(NULL,'%Y-%M-%d') y) y
order by t2.dam_id, t2.birth_date

Results:

| difference | @prev_dam | @prev_value | dam_id | birth_date | @prev_dam := t2.dam_id | @prev_value := t2.birth_date |
|------------|-----------|-------------|--------|------------|------------------------|------------------------------|
|     (null) |    (null) |      (null) |  S6040 | 2008-04-30 |                  S6040 |                   2008-04-30 |
|        351 |     S6040 |  2008-04-30 |  S6040 | 2009-04-16 |                  S6040 |                   2009-04-16 |
|        336 |     S6040 |  2009-04-16 |  S6040 | 2010-03-18 |                  S6040 |                   2010-03-18 |
|     (null) |     S6040 |  2010-03-18 |  S6093 | 2008-04-04 |                  S6093 |                   2008-04-04 |
|        376 |     S6093 |  2008-04-04 |  S6093 | 2009-04-15 |                  S6093 |                   2009-04-15 |
|        353 |     S6093 |  2009-04-15 |  S6093 | 2010-04-03 |                  S6093 |                   2010-04-03 |
|        344 |     S6093 |  2010-04-03 |  S6093 | 2011-03-13 |                  S6093 |                   2011-03-13 |
|        444 |     S6093 |  2011-03-13 |  S6093 | 2012-05-30 |                  S6093 |                   2012-05-30 |
|        351 |     S6093 |  2012-05-30 |  S6093 | 2013-05-16 |                  S6093 |                   2013-05-16 |
|        362 |     S6093 |  2013-05-16 |  S6093 | 2014-05-13 |                  S6093 |                   2014-05-13 |
|     (null) |     S6093 |  2014-05-13 |  S6094 | 2008-03-29 |                  S6094 |                   2008-03-29 |
|        371 |     S6094 |  2008-03-29 |  S6094 | 2009-04-04 |                  S6094 |                   2009-04-04 |
|        409 |     S6094 |  2009-04-04 |  S6094 | 2010-05-18 |                  S6094 |                   2010-05-18 |
|        300 |     S6094 |  2010-05-18 |  S6094 | 2011-03-14 |                  S6094 |                   2011-03-14 |
|       1185 |     S6094 |  2011-03-14 |  S6094 | 2014-06-11 |                  S6094 |                   2014-06-11 |

Query 2:

SELECT dam_id, AVG(difference) age
FROM (
      SELECT
            IF((t2.dam_id=@prev_dam), datediff(t2.birth_date,@prev_value), NULL) difference
          , t2.dam_id
          , @prev_dam := t2.dam_id
          , @prev_value := t2.birth_date
      FROM cattle_info_tbl t2
      CROSS JOIN (SELECT @prev_dam:=null x, @prev_value:=str_to_date(NULL,'%Y-%M-%d') y) y
      ORDER BY t2.dam_id, t2.birth_date
     ) b
GROUP BY dam_id

Results:

| dam_id |      age |
|--------|----------|
|  S6040 |    343.5 |
|  S6093 | 371.6667 |
|  S6094 |   566.25 |

Query 3:

SELECT
       t1.dam_id as cow_id
     , av.age
FROM cattle_info_tbl t1
LEFT JOIN (
          SELECT dam_id, AVG(difference) age
          FROM (
                SELECT
                      IF((t2.dam_id=@prev_dam), datediff(t2.birth_date,@prev_value), NULL) difference
                    , t2.dam_id
                    , @prev_dam := t2.dam_id
                    , @prev_value := t2.birth_date
                FROM cattle_info_tbl t2
                CROSS JOIN (SELECT @prev_dam:=null x, @prev_value:=str_to_date(NULL,'%Y-%M-%d') y) y
                ORDER BY t2.dam_id, t2.birth_date
               ) b
          GROUP BY dam_id
          ) av ON t1.dam_id = av.dam_id
WHERE t1.herd_id = 'H38' AND t1.dam_id<>''

Results:

| cow_id |      age |
|--------|----------|
|  S6093 | 371.6667 |
|  S6093 | 371.6667 |
|  S6094 |   566.25 |
|  S6094 |   566.25 |
|  S6093 | 371.6667 |
|  S6040 |    343.5 |
|  S6094 |   566.25 |
|  S6093 | 371.6667 |
|  S6040 |    343.5 |
|  S6040 |    343.5 |
|  S6093 | 371.6667 |
|  S6094 |   566.25 |
|  S6093 | 371.6667 |
|  S6094 |   566.25 |
|  S6093 | 371.6667 |

NOTE: I think you complicate everything by confusing dam_id with cow_id. This does not appear to be correct. My guess is that animal_id is more likely to be the correct column to relabel as cow_id.

Paul Maxwell
  • 33,002
  • 3
  • 32
  • 51
0

The following will display a method to compare a previous value to the current value in MySQL using some samples of birth_date as the example, See this SQL Fiddle

Setup:

CREATE TABLE Table1
    (`birth_date` datetime)
;

INSERT INTO Table1
    (`birth_date`)
VALUES
    ('2008-03-29 00:00:00'),
    ('2009-04-04 00:00:00'),
    ('2010-05-18 00:00:00'),
    ('2011-03-14 00:00:00'),
    ('2011-05-25 00:00:00')
;

Query:

SELECT
       birth_date
     , IF(@prev_value IS NOT NULL,datediff(birth_date,@prev_value),NULL) difference
     , @prev_value := birth_date
FROM Table1
CROSS JOIN (SELECT @prev_value:=str_to_date(NULL,'%Y-%M-%d')) y
order by birth_date

Results:

|           birth_date | difference | @prev_value := birth_date |
|----------------------|------------|---------------------------|
| 2008-03-29T00:00:00Z |     (null) |       2008-03-29 00:00:00 |
| 2009-04-04T00:00:00Z |        371 |       2009-04-04 00:00:00 |
| 2010-05-18T00:00:00Z |        409 |       2010-05-18 00:00:00 |
| 2011-03-14T00:00:00Z |        300 |       2011-03-14 00:00:00 |
| 2011-05-25T00:00:00Z |         72 |       2011-05-25 00:00:00 |

The third column display what the variable holds at the conclusion of each row, and it is that value which is carried into the next row to allow the dat difference to be calculated.

Paul Maxwell
  • 33,002
  • 3
  • 32
  • 51
  • Hi @Used_By_Already This is the code I generated. [http://sqlfiddle.com/#!9/6f9f63/3] What I want actually the average of difference column. Could you do that? – naqib83 Sep 22 '17 at 04:42
  • Hi @Used_By_Already Ignore the upper comment. This is the code I generated. [http://sqlfiddle.com/#!9/6f9f63/10] What I want actually the average of difference column. Could you do that? And when I run this in MySQL Workbench, it throws the `Error Code: 1242. Subquery returns more than 1 row` And when I run this in SQL Fiddle it show `Operand should contain 1 column(s)` – naqib83 Sep 22 '17 at 05:06
  • You need more than one table to run that query. Also the query you have included in the question and that sqlfiddle isnt complete (eg no groiip by clause). Consider making the query a LOT simpler to start with. – Paul Maxwell Sep 22 '17 at 05:26
  • Check my next comment. – naqib83 Sep 22 '17 at 05:27
  • What next comment? How does it help? You can achieve the wanted calculation by taking the logic have displayed above then aggregating it like any other data. You haven't supplied workable sample data so not possible to much more than I have already. – Paul Maxwell Sep 22 '17 at 06:13
  • Hi @Used_By_Already, I have solved the problem with the help of your solution. But now there is another problem, for different Cow_ID it shows same calve_interval. Each Cow_ID will have their own cow_interval depending on Numb_calves_born. Can you take a look? Here is the updated SQLFiddle http://sqlfiddle.com/#!9/68328f/1 – naqib83 Sep 23 '17 at 20:29
  • You need to include cow_ID into the order by clause and in the IF as conditions – Paul Maxwell Sep 24 '17 at 03:02
  • Hi, Can you take a look or update this SQL Fiddle. This is what I did http://sqlfiddle.com/#!9/68328f/6 But still it gives the same result. – naqib83 Sep 24 '17 at 04:02
0

My overall guess is that you need a "self join" of the cattle information. i.e. some rows in that table refer to cows that have been dams, and other rows refer to bulls that have been sires.

Note I have ADDED some rows to represent dams

SQL Fiddle

MySQL 5.6 Schema Setup:

create table CATTLE_INFO_TBL(
    herd_id     VARCHAR(30),
    chaps_id    BIGINT NOT NULL AUTO_INCREMENT,
    animal_id   varchar(20),
    birth_date  DATE,
    breed       VARCHAR(16),
    reg_no      VARCHAR(30),
    reg_name    VARCHAR(30),
    elec_id     VARCHAR(30),
    sire_chaps_id   BIGINT,
    sire_id     varchar(20),
    dam_chaps_id    BIGINT,
    dam_id      varchar(20),
    cow_age     INT,
    sex     VARCHAR(1), 
    birth_weight    FLOAT,
    birth_weight_status TINYINT(2),
    calving_ease    INT,
    state       VARCHAR(2),
    sex_date    DATE,
    lot_no      varchar(16),
    picture     MEDIUMBLOB,
    PRIMARY KEY (chaps_id)
);

## adding some dams into the detail table
INSERT INTO `cattle_info_tbl` (`herd_id`,`animal_id`,`breed`) VALUES ('H38','S6040','breed of dam');
INSERT INTO `cattle_info_tbl` (`herd_id`,`animal_id`,`breed`) VALUES ('H38','S6093','breed of dam');
INSERT INTO `cattle_info_tbl` (`herd_id`,`animal_id`,`breed`) VALUES ('H38','S6094','breed of dam');

INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',412,'U8104','2008-03-29','ARLOANAN','','','949000000074863',20360,'S6032',10086,'S6094',2,'2',64,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',467,'W9157','2009-04-04','ARLOANAN','','','982000025313627',20425,'UNKNAR',10086,'S6094',0,'2',0,NULL,0,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',559,'XMS15','2010-05-18','LOANANGV','','','',-1,'UNKN',10086,'S6094',4,'0',0,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',593,'Y1057','2011-03-14','LOLOANAN','','','982000172933771',20133,'750S',10086,'S6094',5,'3',80,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',353,'B4189','2014-06-11','ARLOANAN','','','',20447,'W12',10086,'S6094',8,'3',90,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',717,'Z2134','2012-05-30','ARLOLOHH','','','949000000096964',20439,'V162',373,'S6093',6,'3',75,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',221,'A3077','2013-05-16','ARLOLOHH','','','',20447,'W12',373,'S6093',7,'2',75,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',309,'B4045','2014-05-13','ARLOLOHH','','','',20437,'V131',373,'S6093',8,'3',72,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',417,'U8163','2008-04-04','ARLOLOHH','','','949000000008829',20360,'S6032',373,'S6093',0,'2',0,NULL,0,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',478,'W9215','2009-04-15','ARLOLOHH','','','982000128138391',20425,'UNKNAR',373,'S6093',0,'2',0,NULL,0,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',541,'X0145','2010-04-03','ARLOLOHH','','','999000000013145',20440,'V529',373,'S6093',4,'2',80,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',589,'Y1052','2011-03-13','ARLOLOHH','','','982000172933719',20425,'UNKNAR',373,'S6093',5,'2',64,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',436,'U8303','2008-04-30','ARLOANHH','','','949000000077530',20360,'S6032',10082,'S6040',2,'3',70,NULL,1,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',479,'W9217','2009-04-16','ARLOANHH','','','982000025313610',20360,'S6032',10082,'S6040',0,'2',0,NULL,0,'','0000-00-00',NULL,NULL);
INSERT INTO `cattle_info_tbl` (`herd_id`,`chaps_id`,`animal_id`,`birth_date`,`breed`,`reg_no`,`reg_name`,`elec_id`,`sire_chaps_id`,`sire_id`,`dam_chaps_id`,`dam_id`,`cow_age`,`sex`,`birth_weight`,`birth_weight_status`,`calving_ease`,`state`,`sex_date`,`lot_no`,`picture`) VALUES ('H38',519,'X0061','2010-03-18','ARLOANHH','','','999000000013061',20425,'UNKNAR',10082,'S6040',0,'1',0,NULL,0,'','0000-00-00',NULL,NULL);

Query 1:

SELECT
       dams.animal_id
     , dams.breed
     , dams.cow_age
     , av.avdiff
FROM cattle_info_tbl AS dams
INNER JOIN (
          SELECT dam_id, AVG(difference) avdiff
          FROM (
                SELECT
                      IF((t2.dam_id=@prev_dam), datediff(t2.birth_date,@prev_value), NULL) difference
                    , t2.dam_id
                    , @prev_dam := t2.dam_id
                    , @prev_value := t2.birth_date
                FROM cattle_info_tbl t2
                CROSS JOIN (SELECT @prev_dam:=null x, @prev_value:=str_to_date(NULL,'%Y-%M-%d') y) y
                WHERE t2.herd_id = 'H38' AND t2.dam_id<>''
                ORDER BY t2.dam_id, t2.birth_date
               ) b
          GROUP BY dam_id
          ) av ON dams.animal_id = av.dam_id

Results:

| animal_id |        breed | cow_age |   avdiff |
|-----------|--------------|---------|----------|
|     S6040 | breed of dam |  (null) |    343.5 |
|     S6093 | breed of dam |  (null) | 371.6667 |
|     S6094 | breed of dam |  (null) |   566.25 |
Paul Maxwell
  • 33,002
  • 3
  • 32
  • 51
  • Hi @Used_By_Already is there any way I can chat with you? Or share a file? If I can share my whole database then it will make sense to you. What you have explained it's close but not exact. Looking forward to hearing from you. – naqib83 Sep 25 '17 at 02:42
  • Sorry. I'm at work and not able to devote that amount of time. My advice is to simplify each question you may have. You are attempting too much detail in one mega query and this just isn't going to work well (and perhaps give you bad results). Try reading this too: https://stackoverflow.com/help/mcve (& The skills/ discipline of getting to an MCVE will help you!) – Paul Maxwell Sep 25 '17 at 03:12
  • ps: sqlfiddle limits the size of DDL to 8,000 characters and inserts can exhaust that pretty quickly. So sqlfiddle alternatives that may help you http://dbfiddle.uk or http://rextester.com `pps: to arrive at an MCVE we need more than just 1 table` – Paul Maxwell Sep 25 '17 at 03:16
  • Hi, Actually I am new in stackoverflow question/answer. Thanks for telling me about help/mcve. After reading "mcve" I realized that I should have given you the clear picture of tables and explanation of their fields (some fields that matters). I wanted to explain the tables. In fact 3 tables that will clear the actual picture or what I am trying to find. I am making another question with clear tables and their links. I know you are busy with your work but still if you can make sometime for chat (regardless of messenger) I will appreciate it. Thanks a lot for the help till now. – naqib83 Sep 25 '17 at 04:31
  • Pleased to hear you read and understand the mcve concepts, also known as sscce: short, self contained, correct (compilable), example http://sscce.org – Paul Maxwell Sep 25 '17 at 05:04
  • Leave the url to your new question here, I'll do what i can. – Paul Maxwell Sep 25 '17 at 05:05