Consider the relation account (customer, balance) where the customer is a primary key and there are no null values. We would like to rank customers according to decreasing balance. The customer with the largest balance gets rank $1.$ Ties are not broke but ranks are skipped: if exactly two customers have the largest balance they each get rank $1$ and rank $2$ is not assigned.
$\text{Query1:}$
select A.customer, count(B.customer)
from account A, account B
where A.balance <=B.balance
group by A.customer
$\text{Query2:}$
select A.customer, 1+count(B.customer)
from account A, account B
where A.balance < B.balance
group by A.customer
Consider these statements about Query$1$ and Query$2.$
- Query$1$ will produce the same row set as Query$2$ for some but not all databases.
- Both Query$1$ and Query $2$ are a correct implementation of the specification
- Query$1$ is a correct implementation of the specification but Query$2$ is not
- Neither Query$1$ nor Query$2$ is a correct implementation of the specification
- Assigning rank with a pure relational query takes less time than scanning in decreasing balance order assigning ranks using ODBC.
Which two of the above statements are correct?
- $2$ and $5$
- $1$ and $3$
- $1$ and $4$
- $3$ and $5$