0% found this document useful (0 votes)
29 views3 pages

SQL 1

Uploaded by

Satyam Gupta
The document describes creating a CONSIGNOR table with fields for ID, name, address and city. It then inserts 4 records into the table with values for consignors from New Delhi and Mumbai. It also provides sample queries to display names of consignors from Mumbai, count of consignors from each city, and IDs and addresses of consignors from New Delhi.

Copyright:

Attribution Non-Commercial (BY-NC)

Available Formats

Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
29 views3 pages

SQL 1

Uploaded by

Satyam Gupta
The document describes creating a CONSIGNOR table with fields for ID, name, address and city. It then inserts 4 records into the table with values for consignors from New Delhi and Mumbai. It also provides sample queries to display names of consignors from Mumbai, count of consignors from each city, and IDs and addresses of consignors from New Delhi.

Copyright:

Attribution Non-Commercial (BY-NC)

Available Formats

Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 3

5.

SQL> CREATE TABLE CONSIGNOR


2 3 4 5 6 7 ( CNORID VARCHAR(20), CNORNAME VARCHAR(20), CNORADDRESS VARCHAR(20), CITY CHAR(20) );

Table created.
SQL> INSERT INTO CONSIGNOR
VALUES('&CNORID','&CNORNAME','&CNORADDRESS','&CITY'); Enter value for cnorid: ND01 Enter value for cnorname: R SINGHAL Enter value for cnoraddress: 24,ABC ENCLAVE Enter value for city: NEWDELHI old 1: INSERT INTO CONSIGNOR VALUES('&CNORID','&CNORNAME','&CNORADDRESS','&CITY') new 1: INSERT INTO CONSIGNOR VALUES('ND01','R SINGHAL','24,ABC ENCLAVE','NEWDELHI'

1 row created.
SQL> /
Enter value for cnorid: ND02 Enter value for cnorname: AMIT KUMAR Enter value for cnoraddress: 123,PALM AVENUE Enter value for city: NEWDELHI old 1: INSERT INTO CONSIGNOR VALUES('&CNORID','&CNORNAME','&CNORADDRESS','&CITY') new 1: INSERT INTO CONSIGNOR VALUES('ND02','AMIT KUMAR','123,PALM AVENUE','NEWDELH

1 row created.
SQL> /
Enter value for cnorid: MU17 Enter value for cnorname: R KOHLI Enter value for cnoraddress: 5/A,SOUTH STREET

Enter value for city: MUMBAI old 1: INSERT INTO CONSIGNOR VALUES('&CNORID','&CNORNAME','&CNORADDRESS','&CITY') new 1: INSERT INTO CONSIGNOR VALUES('MU17','R KOHLI','5/A,SOUTH STREET','MUMBAI')

1 row created.
SQL> /
Enter value for cnorid: MU50 Enter value for cnorname: S KAUR Enter value for cnoraddress: 27-K, WESTEND Enter value for city: MUMBAI old 1: INSERT INTO CONSIGNOR VALUES('&CNORID','&CNORNAME','&CNORADDRESS','&CITY') new 1: INSERT INTO CONSIGNOR VALUES('MU50','S KAUR','27-K, WESTEND',' MUMBAI')

1 row created.

QUESTIONSQUES1. To display names of all CONSIGNORS from MUMBAI. Ans. SQL> SELECT CNORNAME FROM CONSIGNOR WHERE CITY='MUMBAI'; CNORNAME -----------------R KOHLI S KAUR QUES2. To display number of CONSIGNORS from each CITY. Ans. SQL> SELECT CITY,COUNT(CITY) FROM CONSIGNOR GROUP BY CITY; CITY --------------MUMBAI NEWDELHI COUNT(CITY) ------------------2 2

QUES3. Tell output of : SELECT CNORID, CNORADDRESS FROM CONSIGNOR WHERE CITY=NEWDELHI; Ans. SQL> SELECT CNORID, CNORADDRESS FROM CONSIGNOR WHERE CITY='NEWDELHI';

CNORID ------------ND01

CNORADDRESS -----------------------24, ABC ENCLAVE

You might also like