Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Navigational Result for Query
00:00
5 left

Navigational Result for Query

MediumSQL · PostgreSQL

Problem

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.

Schema

known_destinations
ColumnTypeDescription
query_textVARCHAR(80)Search query text
canonical_domainVARCHAR(80)Known canonical destination domain
search_results
ColumnTypeDescription
query_textVARCHAR(80)Search query text
positionINTDisplayed search-result position
result_domainVARCHAR(80)Domain shown in the result
result_typeVARCHAR(20)Result classification, such as organic or sponsored
Tablesknown_destinationssearch_results
Interviewer

Your question is Navigational Result for Query. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.