Sort and Criteria Pane

Top  Previous  Next

Sort and Criteria Pane

 

Sort and Criteria Pane.

 

Use the Sort and Criteria Pane to Customise your Query Output.  In many circumstances you will not want your query to retrieve every row of data from the selected table in the database.  The UTB provides a number of criteria to enable selective retrieval of the data.

 

Sort_and_criteria_pane1

 

Define your data sorts and data selection criteria you wish to apply to a column.

 

Valid syntax for criteria is =, <, >, <>, Like, Not like, and Between

Other characters that will be of use are % and _

 

 

Column

 

Each of the Table rows selected in the Query Builder Pane is listed.  The database object properties name is displayed in full but will depend on your PC setup.  This name will appear in the Results Pane when the query is executed.

 

If you need to know the properties of any row in the table then this is available in the Data Source Tree Pane by expanding the columns in the required table and right clicking on the required row to display the Properties selection option.  Click on this option to show the field Database Object Properties window.  In the example shown for the SDDOCO_Order_number field; it is 10 numeric characters with no decimal (0 Scale) and 4 bytes long.  This object properties information is not available in the Query Builder Pane.

 

 

Data_source_tree10

 

Selected Columns appear in the list and may be deleted by highlighting and delete.

 

On highlighting a column a drop down arrow appears and on selection shows all the available columns in the table again.  By this means columns may be added to the Query but NOTE the new selected column REPLACES the highlighted column.

 

Sort_and_criteria_pane7

 

Alias

 

The Alias column is blank on initial selection but may be used to rename the Results Column in your query.

 

Sort_and_criteria_pane2

 

In the example shown the first three rows have been renamed from SDDCTO_Order_Type to Order Type, SDDOCO_Order_Number to Order No. and SDLNID_Line_Number to Line No.  (See the effect of this in the Results discussion below).

 

Tables

 

The Tables Column in the Sort and Criteria Pane shows the Table from which the Row was selected.

 

Sort_and_criteria_pane3

 

In the example shown the Rows SDDOCO_Order_Number is from the F4211_Sales_Order_Detail_File and SHVR01_Customer_PO (and two following rows) is from the F4201_Sales_Order_Header_File.

 

Output

 

On selection each output row is selected (Checked) and will appear in the Results Pane. If a table row is required for any form of Sort or selection Criteria then it must be selected in the Query Build Pane and appear here, but if it is NOT required in the Results Pane then it can be unchecked here.

 

Sort_and_criteria_pane4

 

In the example shown the SDRSDJ_Promised_Delivery and SDPA8_Parent_Number are both unchecked and will not appear in the Results Pane.

 

Sort Type and Sort Order

 

The output of your query can be sorted by using the Sort Type and Sort Order columns, which are related to each other. 

 

The Sort Type column has three options to specify the sort sequence of the rows in your query, Ascending, Descending or Unsorted.  On selection of either ascending or descending in the Sort Type field, the level of sort is entered in the Sort Order field.  If subsequently the unsorted option is selected then both Sort Type and Sort Order are cleared.

 

The Sort Order column allows you to specify on which field you wish to sort the data.  The number that you specify within the Sort Order column represents the order in which the query fields are sorted.  The field must be numeric and numbers sequential.

If the Sort Order is selected first then the Sort Type defaults to ascending, but it may be changed to descending.

 

Sort_and_criteria_pane5

 

In the example shown the query will be sorted by Order Type first in ascending type order, followed by Order Number in ascending order and followed by Order lines again in ascending order.  I.e. Order lines within order numbers within order types.

 

Criteria

 

The Criteria columns in the Sort and Criteria Pane are used to apply selection criteria to individual fields, thus allowing greater control of the rows that appear in the Results Pane of your query.

 

The following criteria are typical:

       

 


<>

not equal

<

less than

>

greater than

=

equal to

Like

is like - used in alpha fields with/without %

Not Like

is not like used in alpha fields with/without %

Between

between two numbers

%

used with alpha selects to select any character

_

used with alpha selects to position specified characters in field

 

 

It should be noted that if the = criteria is required then it is automatically entered in the criteria column on tabbing out of the column.  It is NOT NECESSARY to enter it manually.

 

The format required for date criteria entry is important in the Sort and Select Pane.  The format is 'ccyy-mm-dd' i.e. '2006-04-28' and will appear correctly in the SQL statement.   Note: a '/' or '-' separator works).

 

Sort_and_criteria_pane6

 

In the example shown the query will select records where the Order Type is like Sx (where x is any character) and Order numbers are in the range between 2000 and 2650 and the branch plant is like anything with M30 in the last part of the field.

 

 

Other Selection Criteria in SQL and QBE

 

Example

Field Type

Required Result

SQL Statement

QBE Statement

1

Numeric

Equal to a number

60100

60100

2

 

Not Equal to Zero 0

<> 0

<> 0

3

 

Between Two numbers

Between n1 and n2

Between not allowed

4

 

 

>= nnn and <= nnnn

And not allowed

5

 

Not between two numbers

Not between n1 and n2

Not Between not allowed

6

 

Not between two numbers

< n1 OR > n2

Two criteria not allowed in same column

7

 

List of Numbers

IN (n1, n2, n3)

IN not allowed

8

 

NOT a list of numbers

NOT IN (n1, n2, n3)

NOT IN not allowed

 

 

 

 

 

9

Alpha (1Chr)

Equal to a

A

A

10

 

 

a

a

11

 

 

A

A

12

 

 

a

a

13

 

Equal to

14

 

>, <, <>, >=, <=,

Operator A

Operator A

 

 

 

 

 

15

Alpha (>1Chr)

Like a string of Characters

Like %aaaa%

%aaaa%

16

 

Starting string of characters

Like aaaa%

Aaaa%

17

 

Ending string of characters

Like %aaaa  

Note: spaces in field after search characters

%aaaa   %

 

or % aaaa%

18

 

Not like a string

As 15, 16 and 17 above

As 15, 16, and 17 above

19

 

Exclude 'blank' string

<> ''

Not Like '   %'

Not In ('')

<> ''

20

 

Include 'blanks' ONLY

= ''

LIKE '  %'

IN ('')

= ''

21

Date Field

Equal to a specific date

ccyy/mm/dd

ccyy/mm/dd

22

 

<, >, <> a specific date

Operator 'ccyy/mm/dd

Operator ccyy/mm/dd

23

 

Between two dates

Between 'ccyy/mm/dd and 'ccyy/mm/dd

See 3 above

24

 

Date 1 compared to Date 2

Date 1 < Date 2

See 6 above

25

 

 

Date 1 > Date 2

See 6 above

 

 

Other DATE Function Statements.

 

 

Note 1: The date functionality described below is fully applicable to sql Server database applications but NOT YET fully applied to jdeDirect applications.

 

Note 2: JdeDirect versions 2.0.4.5 and later return a blank date in the database as a default of 31/12/1899 in the results column.

 

The following statements may be added to your query SELECT statement by adding the required text in the Sort and Criteria Pane under Column.

 

1. GETDATE()                Returns the current date details

SELECT GETDATE()                = 2007-05-15

 

 

2. DATEPART(item,date) Returns the specified part item of a date date as an integer.

SELECT

DATEPART(yy, getdate())

= 2006

DATEPART(qq, getdate())

= 2 (Quarter 2)

DATEPART(mm, getdate())

= 05 (month of May)

DATEPART(dy, getdate())

= 128 (Day 128 in 2006)

DATEPART(dd, getdate())

= 08 (Date Monday 8th of May)

DATEPART(dw, getdate())

= 02 (day of Week)

DATEPART(wk, getdate())

= 19 (Week number 19 of 2006

 

 

3. DATEDIFF(Item,dat1,dat2) Calculates the difference between the date parts dat1 and dat2 and returns the result as an integer in units specified by the value item.

SELECT

DATEDIFF(yy, ShipDate, getdate())= number of years between Shipdate and current date
DATEDIFF(mm, ShipDate, getdate())= number of months between Shipdate and current date
DATEDIFF(dd, ShipDate, getdate())= number of days between Shipdate and current date

 

Item input can be as detailed above i.e. yy, qq, mm, dy, dd, dw, or wk.

 

 

4. DATEADD(item,number,date)Adds the number number of units specified by the value item to a given date date.        

SELECT

DATEADD(dd,30, Orderdate)Adds 30 days to the OrderDate and returns a new date 30 days later.

 

Note:  The number of units input may also be negative.  Therefore 30 in this example would return a date 30 days earlier.

 

 



Page URL: http://www.unitysolutions.com/Helps/UTB/HTML/index.html?sort_and_criteria_pane.htm