Learning SQL

Learning SQL is easy. Our free online SQL tutorial teaches you the SQL commands you need. We provide examples of SQL syntax so you can learn SQL quickly. Our SQL tutorial is a great SQL command reference.

Table of Contents

Formatting Numbers

By default, Scalable SQL displays numbers using scientific notation. To change the format, you must add a mask.

Syntax:

Select fieldname<mask>, fieldname<mask>, fieldname<mask>
from  tablename;

Explanation:

  • Number masks tell SQL how to display numbers.
  • The symbols in the table below define the format mask.
  • Enclose number masks in brackets.
Number Masks
9 Display number.
Z Display number, drop leading zeros.
+ Display a plus in front of positive numbers.
Display a negative in front of negative numbers.
- Display a negative in front of negative numbers.
Display nothing in front of positive numbers.
( ) Display negative numbers enclosed in parentheses.
. Display decimal point.
$ Display dollar sign.
, Use comma to separate thousands.

Example:

Retrieve the vendor ID, name, and current balance for all vendors. Format the current balance:

  1. In the SQL text box, type:

Select VendId, Name, CurrBal [($Z,ZZZ,ZZZ.99)]
from TrnVendor; 

  1. Execute the statement by clicking on First, the Run button located to the right of the SQL text box. The results will display on the screen.
  2. Click on Stop to return to the original screen.
Results:
VendId Name CurrBal
TV001 Wet Off Towels $13.13
TV002 The Games All Here $453.17
TV003 BedMakers Linen $500.00
TV004 Bed Room Furniture, Inc. $321.70
TV005 Ray Block $1,001.23
TV006 Mosquito No Bite $967.24
TV007 Spot Out $1,606.54
TV008 Big Tree Landscaping $342.98
TV009 Hit the Deck $23.45
TV010 The Soda Factory $0.00
TV011 The Freelance ($109.23)
TV012 Paper People $617.00
TV013 Softer Software $9,873.67
TV014 Counter Productive $42.89
TV015 No Waste Disposal $1,720.98
TV016 Music Maker $4,109.14
TV017 Food Four $642.98
TV018 Computer Bytes $345.09
TV019 Bayshore Consulting $498.05
TV020 BayCon Group $51.00
TV021 Cooperative Operatives $20.00
TV022 Legal Lookup $3,215.16
TV023 World Wide Learning U $771.06
TV024 Enterprise Transport $1,234.98
TV025 Against the Tide $64.72
TV026 Clampett Oil $0.00
TV027 Narrow Nest $1,609.00
TV028 Distant Horizons $26.98
TV029 Paltry Play $1,000.00
TV030 Make Shift Tilts $1,793.23
Table of Contents

Legal Dot Privacy