Consider a relation examinee(regno, name, score), where regno is the primary key and score is a real number. Suppose the relation also has an attribute centr_code that specifies the center where an examinee appears. Write an SQL query to list the centr_code of centers having an examinee whose score is greater than 80.

GATE 2001 · Databases · SQL · medium

Answer: SELECT distinct centr_code FROM examinee WHERE score > 80;

  1. Filter rows with score > 80: Scan the examinee table and keep only those rows where the score column is strictly greater than 80.
  2. Project distinct centr_code: From the filtered rows, project the centr_code column. Use DISTINCT to return each qualifying center exactly once. Final SQL: SELECT distinct centr_code FROM examinee WHERE score > 80;