Minggu, 15 Februari 2009

Microsoft SharePoint Team Blog
The official blog of the Microsoft SharePoint Product Group

Details on Data Analysis


Sorting the Records


Sorting the Records in the Table Window



The lists of records we get with a SELECT statement are presented in the order they have in the table. SQL allows you to arrange records in alphabetical order, in chronological order or in numeric incremental order. After selecting a series of columns, you may want to list the records following an alphabetical order from one specific field. To get an alphabetical or an incremental order of records, you must let the database know what field would be used as reference.

To specify the order, if you are using a Table window:

In the Diagram section, you can right-click a field and select either Sort Ascending or Sort Descending
In the Criteria section of the window, under the Sort Type column, click the corresponding box of the desired column. This would reveal that it is a combo box. Then click the arrow of that combo box and make your selection between Ascending and Descending:

If you select Ascending or Sort Ascending, the list of records would be re-arranged based on the type of the selected column:

If the column is text-based (char, varchar, and their variants), the records would be arranged in alphabetical order
If the column is date or time-based (datetime or smalldatetime), the records would be arranged in chronological order
If the column is number-based, the records would be arranged in incremental order
If the column is Boolean-based (bit), the FALSE records would appear first
If you select Descending or Sort Descending, the list of records would be re-arranged based on the type of the selected column:

If the column is text-based (char, varchar, and their variants), the records would be arranged in reverse alphabetical order
If the column is date or time-based (datetime or smalldatetime), the records would be arranged in reverse chronological order
If the column is number-based, the records would be arranged in decremental order
If the column is Boolean-based (bit), the TRUE records would appear first
After selecting the desired Sort Type, you can execute the SQL statement.


Practical Learning: Using Conditions With Data Analysis



Start Microsoft SQL Server and the SQL Server Management Studio.
If you didn't yet, create the RealEstate1 database
In the Object Explorer, right-click Databases and click New Query
Sorting the Records in the SQL



In SQL, to specify the sorting order, use the ORDER BY expression. The syntax used would be:

SELECT What FROM WhatObject ORDER BY WhatField;
The column used as the basis must be recognized as part of the selected columns. For example, to get a list of students in alphabetical order based on the LastName column, you can use the following statement:

SELECT FirstName,
LastName,
Gender,
ParentsNames,
SPHome
FROM Students
ORDER BY LastName;
GO



source : http://blogs.msdn.com/sharepoint/default.aspx