skip to Main Content

I’m having trouble in fetching the data using aggregate function and BETWEEN clause.

$statusQ = "SELECT COUNT(total_submit_sub) AS noofsub 
            FROM total_noof_sub 
            WHERE sub_name = 'PHP' 
              AND sem = '8'
              AND dept = 'CE'
              AND laborlec = 'Lab'
              AND faculty_name = 'user'
              AND adate BETWEEN '2019/01/01' AND '2019/03/30'";

2

Answers


  1. Chosen as BEST ANSWER
    $statusQ = "SELECT tsid FROM total_noof_sub WHERE sub_name = 'PHP' 
                  AND sem = '8'
                  AND dept = 'CE'
                  AND laborlec = 'Lab'
                  AND faculty_name = 'user'
                  AND adate BETWEEN '$from_date' AND '$to_date' ";
    
                        $countnoofsub = mysqli_query($connect, $statusQ);
                        $num_sub = mysqli_num_rows($countnoofsub);
    

    It will give no. of row, what we want.


  2.  $statusQ = "SELECT COUNT(total_submit_sub) AS noofsub 
                FROM total_noof_sub 
                WHERE sub_name = 'PHP' 
                  AND sem = '8'
                  AND dept = 'CE'
                  AND laborlec = 'Lab'
                  AND faculty_name = 'user'
                  AND convert(DATETIME,adate)   BETWEEN Convert(DATETIME,CASE WHEN isnull(2019/01/01,'')='' THEN adate ELSE isnull(2019/01/01,'') END)     
                  AND Convert(DATETIME, CASE WHEN isnull(2019/03/30,'')='' THEN adate ELSE isnull(2019/03/30,'') END) 
    

    Please Try this Code,
    NULL Part is also Handle….

    Thank You!!!!!!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search