Universal Database (netDB2) Introductory Guide


Sorting And Retrieving Distinct Data

In case the user wants to sort tables in a particular fashion, they can use the "ORDER BY" command. To eliminate the duplicate rows available use the "DISTINCT" command.This helps in avoiding redundancy in the database.

syntax: 
	Select {fields} from {tablename} where {condition} order by {field} 
example:
	Select name , student_id
	from student
	where grade > 'B'
	order by name

This shall give the user an ordered list of all the students in a sorted order ,
which actually means being sorted in alphabetical order .

syntax:
	select distinct {fields} from {tablename} where {condition}

example: 
	select distinct name , job
	from stafftable
	where pay < 10,000
	order by staff_id 

This example, results in all distinct data. As we can notice that the example can have redundant data since name is not a primary key. Using the distinct command one can view data thats not repeated.