code: def query_plate_mjd_fiber(
      n_spectra, primtarget=DEFAULT_TARGET, zmin=0, zmax=0.7
  ):
      """Query the SDSS server for plate, mjd, and fiber numbers
  
      Parameters
      ----------
      n_spectra: int
          number of spectra to query.  Max is 100,000 (set by CAS server)
      primtarget: int
          prime target flag.  See notes below
      zmin, zmax: float
          minimum and maximum redshift range for query
  
      Returns
      -------
      plate, mjd, fiber : ndarrays, size=n_spectra
          The plate numbers MJD, and fiber numbers of the spectra
  
      Notes
      -----
      Primtarget flag values can be found at
      http://cas.sdss.org/dr7/en/help/browser/enum.asp?n=PrimTarget
      """
      query_text = (
          "\n".join(
              (
                  "SELECT TOP %(n_spectra)i ",
                  "  plate, mjd, fiberid ",
                  "FROM specObj ",
                  "WHERE ((PrimTarget & %(primtarget)i) > 0) ",
                  "       AND (z > %(zmin)f)",
                  "       AND (z <= %(zmax)f) ",
              )
          )
          % locals()
      )
  
      output = sql_query(query_text).readlines()
      keys = output[0]
  
      res = np.zeros((n_spectra, 3), dtype=int)
      for i, line in enumerate(output[2:]):
          try:
              res[i] = line.decode().strip().split(",")
          except BaseException:
              raise ValueError(b"\n".join(output))
  
      ntot = i + 1
  
      return res[:ntot].T
  
label_desc: Use image node_id 1 for calling a global function with example usage: query_plate_mjd_fiber(n_spectra, primtarget, zmin, zmax) and returns: res