Professional Documents
Culture Documents
Queries
Queries
Queries
2) Insert rows:
1. Adding a column
Alter table customer
(add country char(50));
2. Dropping a column
Alter table customer
(drop country char(50));
Count counts the number of rows of a particular column you have selected
Distinct returns the unique values of a particular column you have selected
When combined:
Select count(distinct first_name) from customer;
This will first return all the different first names in the table customer and then out of only THAT
particular rows returned, it will count and print out the number
Group by clause when used, returns the rows by grouping them according to the particular column
you have selected. By default it is in ascending order.
This command will return the first_name of customers NOT in the ascending order of their names but
in the ascending order of the address they belong to…so the first preference is given to address…if the
records are abu dhabi, sharjah, deira…dose ppl’s first_name will be printed accordingly…if you want it
in DESCENDING order, just give it as:
Oh ya! There is Order by clause also but it is mainly used to sort a single column in ascending or
descending order…the main difference between these three is kinda difficult to explain here..so ask
me in class if u want!
Birth_Date is of date datatype, so we have to use hash-# ok?? It’s not the same as character
datatype…