Question
Given the following tables: Orders (OrderID,
CustomerID, OrderDate) and Customers (CustomerID, CustomerName, City), what SQL query will return the names of customers who have placed orders in 'New York' within the last 30 days?Solution
The correct query utilizes a JOIN between the Customers and Orders tables on the CustomerID field. This allows you to filter customers who are located in 'New York' and have placed an order in the last 30 days. The JOIN ensures that only customers who have an associated order are included, and the date condition (OrderDate >= CURDATE() - INTERVAL 30 DAY) filters for recent orders. Why Other Options Are Wrong : A) Incorrect : The query attempts to filter customers directly, but it fails to include the necessary JOIN with the Orders table, which is crucial for retrieving orders placed by customers in 'New York'. C) Incorrect : This query incorrectly selects from the Orders table and does not filter by customer details. The City column does not exist in the Orders table. D) Incorrect : This query incorrectly attempts to select data from the Customers table without joining it with the Orders table, so there will be no filtering by order date. E) Incorrect : Although the JOIN is correctly applied, this query places the conditions in the wrong order, and the query logic would still be correct but unnecessarily complex.
Consider the following statement about India extended Line of Credit to Sri Lanka.
I. India has extended 8 Lines of Credit (LOCs) to Sri Lanka ...
Which country has signed a memorandum of understanding with China Road and Bridge Corporation and Atepa Group’s architectural firm for the constructio...
Which of the following statements is/are NOT TRUE with respect to the UPI linkage by NPCIÂ ?
I. The National Payments Corporation of India (NPCI...
Oxford University Press declares ______as Children’s Word of the Year 2021.
Yantra India Limited’s exports increased to what amount in FY 2024–25 from nil in FY 2021–22 (H2)?
Tiger Global and DST Global has sold a 1.8 per cent stake in online food ordering platform Zomato for_________Â through open market transactions.
What is the strategic significance of the Great Nicobar Project as highlighted by the Environment Minister?
Recently In July 2023, PM inaugurated how many EMRS school in Rajasthan?Â
Which department launched the School Health Program in Uttar Pradesh and Lucknow Smart City?
The Indian Institute of Technology ______ bagged the second position among the centrally funded technical institutes in the Centre’s Atal Ranking of ...