Telus Digital does search-quality contract work for a search engine client. Their business rule: a query is 'navigational' if the site's known canonical domain appears anywhere in the top 3 organic (non-sponsored) results. You're given the sample data and the analyst's query below.
CREATE TABLE known_destinations (
query_text VARCHAR(80),
canonical_domain VARCHAR(80)
);
INSERT INTO known_destinations VALUES ('delta airlines', 'delta.com');
-- note: 'best running shoes' has no row here -- it has no single canonical destination
CREATE TABLE search_results (
query_text VARCHAR(80),
position INT,
result_domain VARCHAR(80),
result_type VARCHAR(20) -- 'organic' or 'sponsored'
);
INSERT INTO search_results VALUES
('delta airlines', 1, 'ad.delta-deals.com', 'sponsored'),
('delta airlines', 2, 'expedia.com', 'organic'),
('delta airlines', 3, 'www.delta.com', 'organic'),
('delta airlines', 4, 'tripadvisor.com', 'organic'),
('best running shoes', 1, 'nike.com', 'organic'),
('best running shoes', 2, 'runnersworld.com', 'organic');
SELECT kd.query_text, sr.result_domain AS navigational_match
FROM known_destinations kd
JOIN search_results sr
ON sr.query_text = kd.query_text
AND sr.result_domain = kd.canonical_domain
WHERE sr.position = 1;
Using the sample data above, is there a navigational result for 'delta airlines'? Explain what this query actually returns, whether that's correct per the business rule, and what you'd change.
Use the provided tables and return the corrected matching result, ordered by query and organic result position.
| Column | Type | Description |
|---|---|---|
| query_text | VARCHAR(80) | Search query text |
| canonical_domain | VARCHAR(80) | Known canonical destination domain |
| Column | Type | Description |
|---|---|---|
| query_text | VARCHAR(80) | Search query text |
| position | INT | Displayed search-result position |
| result_domain | VARCHAR(80) | Domain shown in the result |
| result_type | VARCHAR(20) | Result classification, such as organic or sponsored |