[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-763504-105":3,"detail-sidebar-cat-0-en-105":79,"doc-detail-763504-en":129,"doc-similar-763504":159},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":72,"head_meta":74,"extra_data":76,"updated_unix":78},105,"en","sample-sql-questions-with-answers","sample SQL questions with answers","","SQL practice questions focused on writing and completing queries for relational databases using a given schema covering branches, staff, properties, clients, viewing, and registrations, plus an airline schema with customers, flights, and flight information. Tasks include SELECT with filtering, OR, BETWEEN, DISTINCT, aggregates (MIN/MAX/AVG), grouping with HAVING, subqueries with ALL, joins and INTERSECT, and data modification operations like UPDATE and DELETE. An additional set targets passenger counting and flight selection logic across multiple airline-query scenarios.",{"@graph":14,"@context":71},[15,34,54],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/exam/","Exam",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/sample-sql-questions-with-answers/763504/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":48,"encodingFormat":47,"isAccessibleForFree":49,"interactionStatistic":50},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/sample-sql-questions-with-answers/763504.png","ImageObject",300,407,{"name":42,"@type":43},"Jordan Avery","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-30",true,{"@type":51,"interactionType":52,"userInteractionCount":22},"InteractionCounter",{"@type":53},"ViewAction",{"@type":55,"mainEntity":56},"FAQPage",[57,63,67],{"name":58,"@type":59,"acceptedAnswer":60},"What SQL topics are covered in these practice questions?","Question",{"text":61,"@type":62},"The document covers filtering, joins, DISTINCT, aggregation (count/min/max/avg), GROUP BY with HAVING, subqueries (including ALL), set operations (INTERSECT), and update/delete statements.","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"How are date ranges and April 2004 handled in the queries?",{"text":66,"@type":62},"The query for April 2004 uses a BETWEEN condition on the viewing date to count distinct properties viewed within the specified start and end dates.",{"name":68,"@type":59,"acceptedAnswer":69},"Does the airline section include passenger counting and flight selection?",{"text":70,"@type":62},"Yes. It asks for counting passengers on specific flights and dates, finding flights with at least two customers, and determining the most popular destination by aggregating travellers per city.","https://schema.org",{"og:url":32,"og:type":73,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":75,"canonical":32},"index,follow",{"doc_id":77,"site_id":7},763504,1796034068,{"code":4,"msg":80,"data":81},"success",[82,86,90,93,98,103,108,113,118,121,125],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":83,"show_sort_weight":84,"slug":85},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":87,"show_sort_weight":88,"slug":89},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":91,"slug":92},70,"exam",{"id":94,"doc_module":4,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},5,"Comic",60,"comic",{"id":99,"doc_module":4,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},6,"Technology",50,"technology",{"id":104,"doc_module":4,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},7,"Healthcare",40,"healthcare",{"id":109,"doc_module":4,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},8,"Research & Report",30,"research-report",{"id":114,"doc_module":4,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},9,"Religion & Spirituality",20,"religion-spirituality",{"id":116,"doc_module":4,"doc_module_name":25,"category_name":119,"show_sort_weight":116,"slug":120},"World Cup","world-cup",{"id":122,"doc_module":4,"doc_module_name":25,"category_name":123,"show_sort_weight":122,"slug":124},10,"Lifestyle","lifestyle",{"id":126,"doc_module":4,"doc_module_name":25,"category_name":127,"show_sort_weight":94,"slug":128},19,"General","general",{"code":4,"msg":80,"data":130},{"doc_id":77,"user_id":131,"nickname":42,"user_avatar":132,"doc_module":4,"category_id":33,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":22,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":109,"language":138,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":12,"update_tm":78,"read_time":116,"preview_page_count":33,"preview_urls":142},1099523882367,"https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","SQL Practice Questions  \nConsider the following schema definitions:  \nBranch (branchNo, street, city, postcode)  \nStaff (staffNo, fName,lName, position, sex, DOB, salary, branchNo) PropertyforRent (propertyNo, street, city, postcode, type, rooms, rent, ownerNo,  \nstaffNo, branchNo)  \nClient (clientNo, fName, lName, telNo, prefType, maxRent)  \nPrivateOwner (ownerNo, fName, lName, address, telNo)  \nViewing (clientNo, propertyNo, viewDate, comment)  \nRegistration (clientNo, branchNo, staffNo, dateJoined)  \nAn instance of the above schemas is given in the last page of the examination. (You may detach and use it if necessary)  \nFor each case below, fill in the blanks such that the SQL queries correspond to the English language queries stated. Each blank is worth 2 points.  \n1. List the address of all branch offices in London or Bristol.  \nSELECT   *   \nFROM   branch   \nWHERE city=’London’ _OR city=’bristol’   \n2. List the staff with a salary between $10000 and $30000.  \nSELECT staff_No  \nFROM Staff  \nWHERE   salary between 10000 AND 30000   \n3. List the staff in descending order of salary.  \nSELECT staff_No, salary FROM Staff  \nORDER BY   salary DESC   \n4. Find the number of different properties viewed in April 2004.  \nSELECT   count (distinct propert_no) FROM Viewing  \nWHERE viewDate BETWEEN‘1-Apr-04’ AND’30-Apr-04’  \n5. Find the minimum, maximum and average staff salary.  \nSELECT _min(salary)  , _max(salary)_, _avg(salary)  FROM Staff  \n6. For each branch office with more than one member of staff, find the number of staff working in each branch and the sum of their salaries.  \nSELECT branchNo, _count(staffno)_,   sum(salary)  FROM Staff  \nGROUP BY branchNo  \nHAVING   count(staffNo) >1  \n7. List the staff who work in the branch whose stree adress is ‘163 Main Street’  \nSELECT staffNo, fName, lName, FROM Staff  \nWHERE _branchNo  = (SELECT branchNo  \nFROM _branch   \nWHERE _street=’163 Main str’_ )  \n8. Find all staff whose salary is larger than the salary of every staff member at branch with branchNo B003 .  \nSELECT staffNo, fName, lName, position, salary FROM Staff  \nWHERE _salary > ALL  (SELECT salary  \nFROM   staff   \nWHERE brancNo=’B003’)  \n9. For each branch, list the numbers and names of staff who manage properties, including the city in which the branch is located and the properties that the staff manage.  \nSELECT b.branchNo, [b.city](b.city), s.staffNo, fName, lName, properyNo FROM Branch AS b, Staff AS s, _propertyforRent p  \nWHERE b.branchNo = s.branchNo AND _s.staffNo=p.staffno  \n10. List the clients who have viewed a property.  \nSELECT clientNo, fName, lName, propertyNo, viewDate FROM   client natural innerjoin viewing   \n11. Find the list of all cities where there is both a branch office and a property  \n(SELECT city FROM Branch)  \n  INTERSECT   \n(SELECT city  \nFROM _PropertyforRent  )  \n12. Give all managers 5% increase to their salary  \nUPDATE   staff  SET   salary=salary*1.05 WHERE position=’Manager’  \n13. Delete all viewings that belong to property with property number PG4 .  \nDELETE FROM   viewing  WHERE _propertyNo=’P64’   \nA- Consider the following relation schema for an airline database.  \ncustomer(id, name, age, gender)  \nonFlight(id, flightNo, flightDate)  \nflightInfo(flightNo, fromCity, toCity, startTime, duration)  \nAssume all flights take place every day. Fill in the missing slots in each ofd the queries below. Each slot is worth 2 pts, except the first one, which is worth 1 pt.  \n1. Names of all customers above the age of 10  \nSELECT  name  \nFROM customer  \nWHERE   age>10  \n2. Flights (flightNo, flightDate) on which there are at least two customers  \nSELECT f1.flightNo, f1.flightDate  \nFROM onFlight as f1, onFlight as f2  \nWHERE f1.flightNo = f2.flightNo AND f1.flightDate=f2.flightDate AND   [f1.id](f1.id) \u003C> [f2.id](f2.id)  \n3. Flights (flightNo, flightDate) on which there are at least two customers, as well as the number of passengers on the flights  \nSELECT flightNo, flightDate, count(id) as howMany  \nF","cbCaiegNfkld0Xki","https://ap.wps.com/l/cbCaiegNfkld0Xki","pdf",160562,"English","# SQL Practice Questions\n## Branches, Staff, Properties\n## Viewing, Clients, Set Operations\n## UPDATE and DELETE\n## Airline Database Queries","[{\"question\":\"What SQL topics are covered in these practice questions?\",\"answer\":\"The document covers filtering, joins, DISTINCT, aggregation (count/min/max/avg), GROUP BY with HAVING, subqueries (including ALL), set operations (INTERSECT), and update/delete statements.\"},{\"question\":\"How are date ranges and April 2004 handled in the queries?\",\"answer\":\"The query for April 2004 uses a BETWEEN condition on the viewing date to count distinct properties viewed within the specified start and end dates.\"},{\"question\":\"Does the airline section include passenger counting and flight selection?\",\"answer\":\"Yes. It asks for counting passengers on specific flights and dates, finding flights with at least two customers, and determining the most popular destination by aggregating travellers per city.\"}]","sample SQL questions with answers | PDF",[143,147,151,155],{"page_no":22,"url":144,"width":145,"height":146},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-30/8769bd9a50d3dad56eb6ed0c0a5ebafb.webp",983,1272,{"page_no":26,"url":148,"width":149,"height":150},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-30/f3bce784bd22f6d2b41efd0baec55d20.webp",982,1270,{"page_no":30,"url":152,"width":153,"height":154},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-30/8e935e2ac0e607cbf70e13d6de624a67.webp",981,1269,{"page_no":33,"url":156,"width":157,"height":158},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-30/e727aa42c313895236c46c3adf2cdfb2.webp",980,1268,{"list":160,"token":11},[161,168,175,181,188,194,200,206,212,218],{"doc_id":162,"doc_title":163,"file_type":136,"home_preview_img_url":164,"slug":165,"view_count":166,"category_name":29,"create_tm":167},391529,"Top Accenture SQL Interview Questions and Answers - read online free","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917385245/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=%2FNX3wgukDvA3a50A2PbC1YsDuXs%3D","top-accenture-sql-interview-questions-and-answers-read-online-free",16,1790353902,{"doc_id":169,"doc_title":170,"file_type":136,"home_preview_img_url":171,"slug":172,"view_count":173,"category_name":29,"create_tm":174},391746,"SQL TOP50 - Important Interview Questions & Answers","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917704632/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=6a28VIP%2Fqj085IRvoQdvPTO8pYQ%3D","sql-top50-important-interview-questions-answers",15,1790358325,{"doc_id":176,"doc_title":177,"file_type":136,"home_preview_img_url":178,"slug":179,"view_count":126,"category_name":29,"create_tm":180},391653,"Meta Data Engineer Initial Interview Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917399251/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=IWg31vS3aWXTN2HcfHB8ZWUiRcw%3D","meta-data-engineer-initial-interview-guide",1790356632,{"doc_id":182,"doc_title":183,"file_type":136,"home_preview_img_url":184,"slug":185,"view_count":186,"category_name":29,"create_tm":187},391747,"62 SQL Coding interview questions to ask your applicants","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229917705140/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=vRbxE%2FRg8bqGV4r3UX0mwBCqJTM%3D","62-sql-coding-interview-questions-to-ask-your-applicants",17,1790358419,{"doc_id":189,"doc_title":190,"file_type":136,"home_preview_img_url":191,"slug":192,"view_count":186,"category_name":29,"create_tm":193},656144,"Databases Exam - 22 March 2019 - Exam Instructions and Questions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975301640/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=1njtPQY9NrhW7tw%2BgYHpgu%2FiGJI%3D","databases-exam-22-march-2019-exam-instructions-and-questions",1792966704,{"doc_id":195,"doc_title":196,"file_type":136,"home_preview_img_url":197,"slug":198,"view_count":99,"category_name":29,"create_tm":199},646217,"MySQL® for Beginners - SQL-4401 Rev 2.1","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229971804199/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=iScUJGg8C5s2sbdAP2utElD4HMg%3D","mysql-for-beginners-sql-4401-rev-21",1792753729,{"doc_id":201,"doc_title":202,"file_type":136,"home_preview_img_url":203,"slug":204,"view_count":122,"category_name":29,"create_tm":205},267880,"DS-100 Practice Final Questions - Fall 2017","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229898586711/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=pVFXlLslwq8AUT6BMdVDSO9Ga1g%3D","ds-100-practice-final-questions-fall-2017",1789426008,{"doc_id":207,"doc_title":208,"file_type":136,"home_preview_img_url":209,"slug":210,"view_count":94,"category_name":29,"create_tm":211},718156,"800-SQL-Server-questions - SQL Server Interview Questions Answers (More Than 800)","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230018609964/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=vVFjJuD1EjiL4Mt%2BnjgBqNS3jj4%3D","800-sql-server-questions-sql-server-interview-questions-answers-more-than-800",1794854364,{"doc_id":213,"doc_title":214,"file_type":136,"home_preview_img_url":215,"slug":216,"view_count":99,"category_name":29,"create_tm":217},718161,"SQL Interview Questions and Answers - Most Frequently Asked SQL Interview Questions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230019199641/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=%2Fkpq0TIonGqKFJqDLbyKkV%2Bo998%3D","sql-interview-questions-and-answers-most-frequently-asked-sql-interview-questions",1794854380,{"doc_id":219,"doc_title":220,"file_type":136,"home_preview_img_url":221,"slug":222,"view_count":223,"category_name":29,"create_tm":224},678108,"DATABASE MANAGEMENT SYSTEM - LECTURE NOTES - UNIT 1 INTRODUCTION TO DATABASE MANAGEMENT SYSTEM AND ENTITY RELATIONSHIP MODEL","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229994799943/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796202119&Signature=vbvdRVEwqEhQoXPSymOh5ITTOrI%3D","database-management-system-lecture-notes-unit-1-introduction-to-database-management-system-and-entity-relationship-model",12,1793784450]