Data Presentation

Learn the presentation of data through distinct, aliases, stored procedures, views, and top functions.

All the examples below refer to the “Prod.Products” table.

Prod.Products Table

ProductID

ModVersion

Color

ModuleName

ModDescr

DatabaseIncl

UnitPrice

1

1.0

Red

Module A

Interface for using GIS maps

Yes

1000.00

2

1.0

Blue

Module B

Database system that allows them to enter spatial data


Yes

1500.00

3

1.0

Green

Module C

Email application that sends emails based on spatial preferences


No

750.00

4

1.0

Red

Module D

Hosting service for all modules

Yes

2500.00

The DISTINCT function

The DISTINCT function allows us to obtain all unique values from a group of values. This function is beneficial when there are duplicates in a column in particular.

Note: We can only use the DISTINCT function on one column, but we can still select non-unique values from other columns after using the DISTINCT function.

For example, the Prod.Products table contains various product colors, and some colors appear more than once on the table. However, we’d like to gather a unique list of colors in that table. We can do that using the following syntax:

Press + to interact
SELECT DISTINCT Color
FROM Prod.Products

We want to know which specific colors are available in the Prod.Products table. This will output three colors as our “Prod.Products” table contains four rows with two distinct colors:

Output of DINSTINCT

Results


Color

1

Red

2

Green

3

Blue

Aliases

Aliases are temporary names used for tables and columns for queries within the database. They can be used to make certain columns or tables look easier to understand for the user or to keep the true identity of the column or table names a secret. It’s also beneficial to use aliases when writing complex queries, as it can simplify table and column names—thereforemaking the query-writing process quicker.

We can also create string aliases and ...