T-SQL: Divide

Please see my other Database Development articles.


Performing division on integer values.

Often, recordsets contain values that naturally reveal metrics that provide helpful insight into the data.
In this example, I list records about people. Each record contains information about a person’s age, gender and name.

1-t-sql-divide

First, I list each person’s age, the sum of all peoples’ ages, then their age as a percentage compared against the total of all ages.

2-t-sql-divideHere is the final resultset.

3-t-sql-divide

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s