def megapipe_query_sql(ra, dec, size):
    """ 
    Return SQL query command of CFHT megapipe

    Parameters:
        ra (float): in degree
        dec (float): in degree
        size (float): in degree

    Returns:
        url (str): The query URL, need to be opened by `wget` or `curl`.
    """
    
    return ("https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/tap/sync?REQUEST=doQuery&LANG=ADQL&FORMAT=CSV&QUERY="
            "SELECT * "
            "FROM caom2.Observation AS o JOIN caom2.Plane AS p ON o.obsID=p.obsID "
            "WHERE INTERSECTS(p.position_bounds, CIRCLE('ICRS', " + str(ra) + ', ' + str(dec) + ', ' + str(size) + ')) = 1 '
            "AND p.calibrationLevel >= 1 AND o.collection='CFHTMEGAPIPE' ")
            #"AND o.observationID LIKE 'MegaPipe%'")