Git Product home page Git Product logo

sql-queries-for-a-sample-database's Introduction

DATABASE CLASS ASSIGNMENT

Given ER Diagram:

Given ER Diagram Image

Write Queries for:

  1. List the customer name, check number, payment date and amount for the customer with customer number 1001.
  2. List the employee number, last name and first name for all the employees who reports to their manager with employee id 1001.
  3. List the customer name, phone and total amount of all customers with credit limit greater than 10000.
  4. List all the order number, order date, product code, product name, quantity ordered, price each for the customer with customer number 1001.

Queries:

1

SELECT customerName,checkNumber,paymentDate,amount 
FROM customers
JOIN payments
WHERE customers.customerNumber = 1001;

2

SELECT employeeNumber, lastName, firstName, reportsTo
FROM employees
WHERE reportsTo = 1001 ;

3

SELECT customerName, phone, SUM(payments.amount)
FROM customers
JOIN payments
ON customers.customerNumber = payments.customerNumber
WHERE creditLimit > 10000 
GROUP BY payments.amount;

4

SELECT orderdetails.orderNumber, orders.orderDate, products.productCode, orderdetails.quantityOrdered, products.buyPrice
FROM orders
INNER JOIN orderdetails ON orders.orderNumber = orderdetails.orderNumber 
INNER JOIN products on orderdetails.productCode = products.productCode
WHERE orders.customerNumber = 103;

sql-queries-for-a-sample-database's People

Contributors

samarthdubey5 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.