Question

In: Computer Science

Write and run SQL statements to complete the following tasks Show the details of the vendors...

Write and run SQL statements to complete the following tasks

  1. Show the details of the vendors who are located in area code 615.
  2. Show the details of the products that do not have a value for the attribute v_code.
  3. Show the details of the invoices whose subtotal is greater than 25 but less than 75.
  4. Show the details of the invoice who has the minimum subtotal.
  5. Show the codes and names of the vendors who supplied products.
  6. Using EXCEPT show the codes of the vendors who did not supply any products.
  7. Using ‘NOT IN’ show the codes and names of the vendors who did not supply any products.
  8. List the codes of vendors and the number of products each vendor has supplied, i.e. vendor XXX has supplied xxx products, and vendor YYY has supplied yyy products etc.
  9. List the names and codes of vendors and the number of products each vendor has supplied, i.e. vendor XXX has supplied xxx products, and vendor YYY has supplied yyy products etc.
  10. Add a new attribute (field) status varchar(6) to the EMP table.
  11. Update status for employee '100' to 'Temporary'.
  12. Using inner join, list the details of the products whose line price is greater than 100.

You are required to answer

1.   The SQL statements for each query, which should be copied and pasted into word.

2. tell all the sql command for each question?

tables: -

VENDOR TABLE

V_CODE

V_NAME

V_CONTACT

V_ARAECODE

V_PHONE

V_STATE

V_ORDER

PRODUCT TABLE

P_CODE

P_DESCRIPT

P_INDATE

P_QOH

P_MIN

P_MIN

P_DISCOUNT

V_CODE

CUSTOMER TABLE:

CUS_CODE

CUS_LNAME

CUS_FNAME

CUS_INITIAL

CUS_AREACODE

CUS_PHONE

CUS_BALANCE

INVOICE TABLE:

INV_NUM

CUS_CODE

INV_DATE

INV_SUBTOTAL

INV_TAX

INV_TOTAL

LINE TABLE:

INV_NUMBER

LINE_NUMBER

P_CODE

LINE_UNITS

LINE_PRICE

LINE_TOTAL

EMPLOYEE TABLE:

EMP_NUM

EMP_TITLE

EMP_LNAME

EMP_FNAME

EMP_INITIAL

EMP_DOB

EMP_HIRE_DATE

EMP_AREACODE

EMP_PHONE

EMP_MGR

Solutions

Expert Solution

  1. Show the details of the vendors who are located in area code 615.

VENDOR TABLE DATA

1

ABC

9999999999

610

0222290750

GUJARAT

200

2

XYZ

8888888888

615

0283224466

GUJARAT

615

3

PQR

7777777777

615

0283224466

GUJARAT

615

QUERY:

SELECT * FROM VENDOR_MASTER WHERE V_AREACODE = '615'

ANSWER:

2 XYZ   8888888888 615   0283224466 GUJARAT     615

3 PQR   7777777777 615   0283224466 GUJARAT     615

  1. Show the details of the products that do not have a value for the attribute v_code.

PRODUCT TABLE

P_CODE

P_DESC

1

PRODUCT IS GOOD

2019-10-02

100.00

10.00

10.00

NULL

2

PRODUCT IS VERY HEALTHY

2019-10-03

200.00

5.00

5.00

1

3

PRODUCT IS VERY ENERGETIC

2019-10-03

250.00

5.00

5.00

2

QUERY:

SELECT * FROM PRODUCT_MASTER WHERE V_CODE IS NULL

1 PRODUCT IS GOOD   2019-10-02 100.00      10.00 10.00 NULL

  1. Show the details of the invoices whose subtotal is greater than 25 but less than 75.

1

1

2019-02-10

15.00

10.00

25.00

2

2

2019-03-10

28.00

10.00

38.00

3

3

2019-03-10

65.00

10.00

75.00

4

4

2019-03-10

10.00

10.00

20.00

QUERY:

YOU CAN USE BOTH QUERY

SELECT * FROM INVOICE_MASTER WHERE INV_SUBTOTAL BETWEEN 25 AND 75

SELECT * FROM INVOICE_MASTER WHERE INV_SUBTOTAL >= 25 AND INV_SUBTOTAL <= 75

2     2     2019-03-10 28.00 10.00 38.00

3     3     2019-03-10 65.00 10.00 75.00

  1. Show the details of the invoice who has the minimum subtotal.

1

1

2019-02-10

15.00

10.00

25.00

2

2

2019-03-10

28.00

10.00

38.00

3

3

2019-03-10

65.00

10.00

75.00

4

4

2019-03-10

10.00

10.00

20.00

QUERY:

SELECT MIN(INV_SUBTOTAL) FROM INVOICE_MASTER

10.00

  1. Show the codes and names of the vendors who supplied products.

QUERY:

SELECT * FROM PRODUCT_MASTER

1      PRODUCT IS GOOD            2019-10-02   100.00 10.00 10.00 NULL

2      PRODUCT IS VERY HEALTHY    2019-10-03   200.00 5.00   5.00   1

3      PRODUCT IS VERY ENERGETIC 2019-10-03   250.00 5.00   5.00   2

SELECT * FROM VENDOR_MASTER

1     ABC   9999999999 610   0222290750 GUJARAT     200

2     XYZ   8888888888 615   0283224466 GUJARAT     615

3     PQR   7777777777 615   0283224466 GUJARAT     615

SELECT V.V_CODE,V.V_NAME FROM VENDOR_MASTER V INNER JOIN PRODUCT_MASTER P ON V.V_CODE = P.V_CODE

1     ABC

2     XYZ

  1. Using EXCEPT show the codes of the vendors who did not supply any products.

QUERY:

SELECT V.V_CODE FROM VENDOR_MASTER V LEFT JOIN PRODUCT_MASTER P ON V.V_CODE = P.V_CODE

EXCEPT

SELECT V.V_CODE FROM VENDOR_MASTER V RIGHT JOIN PRODUCT_MASTER P

   ON V.V_CODE = P.V_CODE

V_CODE

3

  1. Using ‘NOT IN’ show the codes and names of the vendors who did not supply any products.

QUERY:

SELECT V.V_CODE,V.V_NAME FROM VENDOR_MASTER V INNER JOIN PRODUCT_MASTER P ON V.V_CODE = P.V_CODE

WHERE V.V_CODE NOT IN (SELECT VS.V_CODE FROM VENDOR_MASTER VS WHERE VS.V_CODE IS NULL)

1     ABC

2     XYZ

  1. List the codes of vendors and the number of products each vendor has supplied, i.e. vendor XXX has supplied xxx products, and vendor YYY has supplied yyy products etc.

QUERY:

SELECT V.V_CODE, V.V_NAME, COUNT(*) AS TOTAL FROM VENDOR_MASTER V INNER JOIN PRODUCT_MASTER P ON V.V_CODE = P.V_CODE GROUP BY V.V_CODE

V_CODE    TOTAL

1           1

2           1

  1. List the names and codes of vendors and the number of products each vendor has supplied, i.e. vendor XXX has supplied xxx products, and vendor YYY has supplied yyy products etc.

QUERY:

SELECT V.V_CODE, V.V_NAME FROM VENDOR_MASTER V INNER JOIN PRODUCT_MASTER P ON V.V_CODE = P.V_CODE

V_CODE     V_NAME

1           ABC

2           XYZ

  1. Add a new attribute (field) status varchar(6) to the EMP table.

STATUS      varchar(6)

  1. Update status for employee '100' to 'Temporary'.

QUERY:

UPDATE EMPLOYEE SET STATUS = 'Temporary' WHERE STATUS = '100'

GET ERROR:

MORE THEN 6 CHARACTER

String or binary data would be truncated.

The statement has been terminated.

  1. Using inner join, list the details of the products whose line price is greater than 100.

QUERY:

SELECT P.P_CODE FROM PRODUCT_MASTER P INNER JOIN LINE L ON P.P_CODE = L.P_CODE WHERE L.LINE_PRICE >= '100.00'

IF ANY KIND OF SUGGESTION SO MENTION IN COMMENT


Related Solutions

Write and run SQL statements to complete the following tasks Show the details of the employees...
Write and run SQL statements to complete the following tasks Show the details of the employees who are located in area code 901 and their manager employee number is 108. Show the details of the employees who are also mangers. Show the details of the customers whose balance is greater than 220 but less than 500. Show the details of the customers whose balance is highest. Show customer 10014’s name and the product’s descriptions which he/she purchased and the number...
Write and run SQL statements to complete the following tasks. Show customer 10014’s name and the...
Write and run SQL statements to complete the following tasks. Show customer 10014’s name and the product’s descriptions which he/she purchased and the number of units of each. Add a new attribute (column) engaged varchar(3) to the customer table and update the engaged attribute for the customers who have not generated any invoice to ‘No’. Task 2 should be completed in two steps i.e. two SQL commands. Sql file -- Creating Tables .headers on .mode column .separator , DROP TABLE...
Create one sql script file to complete the following. You cannot run separate SQL statements for...
Create one sql script file to complete the following. You cannot run separate SQL statements for the homework. You will also need to place a semicolon after each SQL statement, a requirement for SQL files containing multiple SQL statements Lesson 3 Write a query to display the current date. Label the column DATE. Display the last name of all employees who have an A and an E in their last name. For each employee, display the employee number, last_name, salary,...
Can you please explain and show how you would complete the following SQL Injection Attacks tasks...
Can you please explain and show how you would complete the following SQL Injection Attacks tasks using the SEED lab seed Ubuntu 16.04 Virtual Machine: Task 3.1: Modify your own salary. As shown in the Edit Profile page, employees can only update their nicknames, emails, addresses, phone numbers, and passwords; they are not authorized to change their salaries. Assume that you (Alice) are a disgruntled employee, and your boss Boby did not increase your salary this year. You want to...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2. 10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create...
Based on the tables below, write SQL command to perform the following tasks for MySql: Create SALESREP and CUSTOMER tables Create primary and foreign keys as appropriate. The custNo should use a surrogate key as the primary key with auto-increment increase the balance of the Gonzales account by $100 to a total of $450? Find an average customer balance Display the name of the sales representative and the name of the customer for each customer that has a balance greater...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an...
Write the following SQL queries and show the corresponding output of the DBMS: 1) Write an SQL statement to display all the information of all Nobel Laureate winners. 2) Write an SQL statement to display the string "Hello, World!". 3) Write an SQL query to display the result of the following expression: 2 * 14 +76. 4) Write an SQL statement to display the winner and category of all Laureate winners. 5) Write an SQL query to find the winner(s)...
Assignment Details: Perform the following tasks: Complete the reading assignment and the interactive lesson before attempting...
Assignment Details: Perform the following tasks: Complete the reading assignment and the interactive lesson before attempting this assignment. Select a recent news article about a life event of an individual. It can be health related, accident related, educational, or even achievement-oriented. It will be one "slice in the lifespan of that person." For example, you might select a story of someone who has achieved a major goal in life after experiencing a debilitating accident. An example would be Nick Vujicic....
In this assignment, you are required to write the SQL statements to answer the following queries...
In this assignment, you are required to write the SQL statements to answer the following queries using PostgreSQL system. The SQL statements comprising the DDL for Henry Books Database are given to you in two files. For that database, answer the following queries. Create the files Q1 to Q10 in PostgreSQL. Do follow the restrictions stated for individual queries. 1. List the title of each book published by Penguin USA. You are allowed to use only 1 table in any...
Please write shell scripts in Kali Linux to complete the following tasks. Task A - Take...
Please write shell scripts in Kali Linux to complete the following tasks. Task A - Take your UIN Write a script like below that reads and displays the MIDAS ID if the following requirements are satisfied: Only lower case letter [a-z] and numeric character[0-9] are allowed MIDAS ID must between 4 to 8 digits Test your script with the following examples: Your MIDAS ID in lower case Your MIDAS ID w.one upper case A string less than 4 digits A...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT