Answer The Following Questions: Table: Charity

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1.

Answer the following questions: Table: Charity

1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17)

Create a database Contribution. (1) Show the structure of the above. (1) Create the above table. (3) Insert the above records. (2) Display all first names in lowercase (1) Display all last names of people of Mumbai city in uppercase (1) Display Person Id along with First 3 characters of his/her name. (1) Display first name concatenated with last name for all the employees. (1) Display length of address along with Person Id (1) Display last 2 characters of City and Person ID. (1) Display Last Names and First names of people who have "at" in the second or third position in their first names. (1) Display the position of 'a' in Last name in every row. (1) Display Last Name and First name of people who have "a" as the last character in their First names. (1) Display the first name and last name concatenated after removing the leading and trailing blanks. (1) Display Person Id, last names and contribution rounded to the nearest rupee of all the persons. (1) Display Person Id, last name and contribution with decimal digits truncated of all the persons. (1) Display Last name, contribution and a third column which has contribution divided by 10. Round it to two decimal points. (1)

1) CREATE DATABASE CONTRIBUTION; 2) DESCRIBE CONTRIBUTION; 3) CREATE TABLE CHARITY a. (P_ID INTEGER(3), b. LASTNAME VARCHAR(20), c. FIRSTNAME VARCHAR(20), d. ADDRESS VARCHAR(30), e. CITY VARCHAR(20), f. CONTRIBUTION FLOAT(7,2)); 4) INSERT INTO CHARITY VALUES(1,BINDRA,JASPREET,5B, GOMTI NAGAR,LUCKNOW,3500.00); a. SIMILARLY OTHER RECORDS. 5) SELECT LCASE(FIRSTNAME) FROM CHARITY; 6) SELECT UCASE(LASTNAME) FROM CHARITY WHERE CITY=Mumbai; 7) SELECT P_ID+LEFT(FIRSTNAME,3) FROM CHARITY; 8) SELECT CONCAT(FIRSTNAME,LASTNAME) FROM CHARITY; 9) SELECT LENGTH(ADDRESS+P_ID) FROM CHARITY; 10) SELECT RIGHT(CITY,2)+P_ID FROM CHARITY; 11) SELECT LASTNAME,FIRSTNAME WHERE INSTR(at,FIRSTNAME)=2 OR INSTR(at,FIRSTNAME)=2; 12) SELECT INSTR(a,LASTNAME) FROM CHARITY; 13) SELECT LASTNAME,FIRSTNAME WHERE FIRSTNAME LIKE%a; 14) SELECT TRIM(FIRSTNAME+LASTNAME) FROM CHARITY; 15) SELECT P_ID,LASTNAME,ROUND(CONTRIBUTION,0) FROM CHARITY; 16) SELECT P_ID,LASTNAME,ROUND(CONTRIBUTION,0) FROM CHARITY; 17) SELECT LASTNAME, CONTRIBUTION, ROUND(CONTRIBUTION/10,2) FROM CHARITY;

You might also like