Presentation is loading. Please wait.

Presentation is loading. Please wait.

Training Course #1: Query Designing Training Course #1: Query Designing Please view in slide show Page Down/Up or mouse click to navigate through the show.

Similar presentations


Presentation on theme: "Training Course #1: Query Designing Training Course #1: Query Designing Please view in slide show Page Down/Up or mouse click to navigate through the show."— Presentation transcript:

1 Training Course #1: Query Designing Training Course #1: Query Designing Please view in slide show Page Down/Up or mouse click to navigate through the show

2 An opportunity overdue for closing An opportunity overdue for closing Sales reps with fewer than 6 activities this week Sales reps with fewer than 6 activities this week A client whose credit status was changed A client whose credit status was changed KnowledgeSync lets you design queries. The only requirement for designing queries is a thorough understanding of an applications database schema. Queries can check for virtually any condition of data in an application, such as: A query identifies a condition of data within an application that should cause an event to trigger. Queries

3 An event may use multiple queries to check for a complex combination of conditions, such as: Checking for customers who have purchased < $10,000 over the last year, but have called into support more than 12 times. A query is one component of an event. A single event may use a single query, or it may use multiple queries. Queries & Events (I)

4 An event may also use multiple queries to check for conditions across multiple applications, such as: An event that looks for customers who have pending sales (in a CRM application) But are also on credit hold (in a financial application) Queries & Events (II)

5 A single query may also be used in multiple events. For example, a query that checks for pending sales > x dollars may be used in: An event that looks for sales > $10,000 and in An event that looks for sales > $25,000 and in An event that looks at sales > $50,000 Queries & Events (III)

6 Designing a Query (click here) Please select the component of KnowledgeSync Query Designing that you would like to learn about next: Designing Linked Queries (click here) What to Do Next (click here) Query Designing Helpful Hints (click here) Exit Presentation Tour Menu

7 All query designing is done in the KnowledgeSync Event Manager. Log into that module (username Admin, no password). You will be presented with a window like the following: How to Begin

8 Return to Tour Menu We will design a query for the Training application. Click on the plus sign (+) next to the Training Application in order to display the sub-branches beneath it.

9 Well be working in the Query Definitions branch. Click on the Query Definitions branch to display a list of pre-defined queries for the Training application. Return to Tour Menu

10 Queries can be divided into three groups: Record-Level Queries Aggregate Queries Value-Change Queries Return to Tour Menu

11 Record-level queries are those that are triggered by the condition of individual database records. These queries look for specific conditions in database records, and, if those conditions are met, the query is triggered. (The queries with the arrows pointing at them are record-level queries.) Return to Tour Menu

12 Aggregate queries are those that are triggered by a group of records that meet a certain threshold. These queries look for specific conditions in database records, then perform an aggregate test on that group of records, and, if both the record-level and aggregate conditions are met, the query is triggered. (The queries with the arrows pointing at them are aggregate queries.) Return to Tour Menu

13 Value Change queries are those that are triggered when a records value has been changed. These queries are very useful, as they enable you to detect when someone has changed the value of any field in an application. (The queries with the arrows pointing at them are value-change queries.) Return to Tour Menu

14 1)The list on the right shows examples of the types of conditions that you can detect using a query. 2)Click on the New Query Definition button at the top-left of this window to create a new query... Return to Tour Menu

15 When designing a query, the first thing you specify is the querys name and whether it can be used in an event. Return to Tour Menu

16 The Active flag simply indicates that this query is eligible to be used in one or more events. Return to Tour Menu

17 KnowledgeSync automatically displays all of the tables from the corresponding application. The first step in designing a query is to identify which tables contain the information you wish to test against for certain conditions. You simply click on the table name you wish to include in this query, and then click on the Add Table button. Return to Tour Menu

18 This query will be designed to retrieve any orders that were picked today but have not been invoiced. We select the Order Header table since that is where general order information is stored. We select the AR Customer table since that lets us retrieve the customers name. (The orders table stores only the customers account number.) And we select the Salesperson table since that lets us retrieve the name of the salesrep associated to the order. Return to Tour Menu

19 1) If multiple tables are selected, KnowledgeSyncs intelligent linking wizard helps you link (or join) the tables together. 2) Its VERY important which table you select FIRST when creating these links. You MUST specify the querys primary table – that is, the table that contains the records that will cause this query to trigger. Since this query is designed to retrieve orders, the Orders table must be the first table we link from. Return to Tour Menu

20 Click on the Add Table Link button. Return to Tour Menu

21 Since this is our first link, we start out by choosing the Orders table. Return to Tour Menu

22 KnowledgeSync automatically fills in the Link to table name, which we can either keep or override. Return to Tour Menu

23 Tables are linked together via a common field (column) of data. Once we specify the name of the column in the Orders table that contains the customer number, KnowledgeSync automatically searches for (and loads) the corresponding field from the Customer table. (And the Link Type automatically defaults to Left Outer Join which is the standard linking method in business applications.) Return to Tour Menu

24 Once we save our first link, we are ready to follow the same steps to link the Orders and Salesreps tables. Return to Tour Menu

25 Note that if the database (or ODBC driver) that you are using does not support standard linking syntax, you can click on the checkbox below and manually enter the SQL from clause that links the tables together. Return to Tour Menu

26 The Columns tab is where you select the fields of data that you might wish to include in an outgoing alert message and in an events response actions when this querys conditions are met. The list titled Available Columns to Query at the top of this tab is a list of all the fields of data from the tables you selected previously. Return to Tour Menu

27 For example, if you wish to use the customers order number in an alert message or response action, you simply highlight the corresponding field in the list at the top of this window and click on the button called Add Column to Query. Return to Tour Menu

28 We would continue adding fields until we had all the information that we might wish to use in an events alert messages or response actions. Return to Tour Menu

29 When creating a record-level query, the Column Type field for all the columns is always left as Normal. This means that KnowledgeSync will retrieve the actual value of that column. Return to Tour Menu

30 When creating an aggregate query, you can choose from five additional Column Types. Typically, an aggregate query checks for conditions such as: -- More Than $50,000 in sales last week -- An average discount percent greater than 7% -- More than 25 support calls this week Here are a few examples: Return to Tour Menu

31 This query uses an aggregate to summarize (or total) the forecast sales per salesrep. This first column selected indicates what field will have its value summarized. The second column selected indicates how the summarized total will be grouped. (Per salesrep) If the second column had been company name instead of salesrep, the sales would be totaled per company instead of per salesperson. (And if company is chosen as a third column, you will get a list showing the forecast sales per salesrep and then – within each salesrep – you would see the sales further broken down by company.) Return to Tour Menu

32 This query identifies any support reps whose average call duration is greater than x minutes. This first column indicates that the average call time will be determined. The second column indicates that the average time will be grouped per support rep. If the second column had been customer name instead of support rep, the average call duration would be calculated per customer instead of per support rep. Return to Tour Menu

33 This query counts the number of activities per salesrep and identifies anyone who has fewer than x scheduled activities. When using the count function, you should always count the column that uniquely identifies each record within a table (e.g., order ID, customer ID, activity ID, etc.). The second column indicates how the counted records will be grouped. (Per salesrep) If the second column had been activity priority instead of salesrep name, the activities would be counted per priority instead of per salesperson. (And if priority is chosen as a third column, you will get a list showing the number of activities per salesrep – broken down by priority.) Return to Tour Menu

34 Sometimes youll find that an application uses column names that are cryptic or difficult to understand. In some applications, column names with multiple words are all squeezed together. Using the Customized Name field, we can change the default names to something more intuitive, or more readable. Return to Tour Menu

35 Note how we have modified the column names to make them clearer. (Since some ODBC drivers dont like blank spaces in a columns customized name, you should use the underline character to separate words.) Return to Tour Menu

36 Notice the Unique column. When KnowledgeSync finds a record that meets a querys criteria, the record is considered triggered. You need to tell KnowledgeSync how it can remember which records have been triggered. This is what the Unique checkbox is for. Return to Tour Menu

37 Since the Order Number uniquely identifies each order, it will also allow KnowledgeSync to remember which order records have been triggered. And so we place a checkmark in the Unique column for the Order Number field. Return to Tour Menu

38 Finally, note how you can create columns that use calculations to derive entirely new values. In this example, the query is multiplying an opportunitys close probability times the forecast amount of the sale (and then is multiplying that total by.01) to derive the weighted value of the sale. Return to Tour Menu

39 When KnowledgeSync sends out an alert message, it can roll-up the details of multiple records into a single message. As a result, you need the ability to specify the order in which the triggered records are displayed. This is called the sorting order. Return to Tour Menu

40 In the case of this query, we might want to list the matching orders according to their order date, with the earliest orders listed first. Just like in the Columns tab, we can sort by any fields from the tables we selected. In the Sort Direction field, we can choose either Ascending or Descending. Return to Tour Menu

41 You can even specify nested sorting. In this query, if multiple orders have the same order date, the orders will then be listed in the alphabetic order by the customers name. Return to Tour Menu

42 The Filters tab is the most important part of a query. It is where you specify what conditions have to occur in order for the query to be triggered. The way a filter works is for you to specify a field, (such as order total) an operator (such as is greater than) and a compare value (such as 1000 dollars). Heres how its done... Return to Tour Menu

43 The list of Available Columns to Filter lists all of the fields from the tables you selected for this query. You start by selecting the field you wish to test for a specific condition. Return to Tour Menu

44 A filter can retrieve records that meet a certain condition (is) or it can retrieve records that do not meet a certain condition (is not). Return to Tour Menu

45 KnowledgeSync supports all standard operators, including checking for records with a null or blank value. Return to Tour Menu

46 A filters Compare Value can contain different types of values. For starters, you can compare the value in a field against a constant value. In this example, the order status must be equal to Picked. Return to Tour Menu

47 You can compare the value in one field against the value in another database field. In this example, note how the query is checking to see if an items on-hand quantity is less than its re-order level. Return to Tour Menu

48 You can even compare the calculated value of two or more fields against the value of a constant, against the value of another database field, or against the value of another calculated field. In this example, the filter is adding the number of units on hand to the number of units on purchase order, and is then comparing that total to see if it is less than the quantity on back order plus the quantity on existing sales orders. Return to Tour Menu

49 KnowledgeSync also lets you perform date-related comparisons using an extensive list of date variables. If you click on the list button that appears in this field, youll be presented with a window like the following... Return to Tour Menu

50 And over on the left you can choose from a wide variety of date substitution variables so that KnowledgeSync can automatically determine the dates that it should use in this query. Return to Tour Menu

51 And so you can identify important business events that occur today, tomorrow, yesterday, or even from last Monday through last Friday. You can even identify events that have (or have not) occurred within the past x days or that will occur within the next y days. Return to Tour Menu

52 KnowledgeSync also lets you query the underlying database for a list of possible values for a field. If you click on the list button that appears in this field, youll once again see the following window... Return to Tour Menu

53 Up in this field, you can display a list of valid field values from your underlying database. Return to Tour Menu

54 Lastly, you can soft-code a filter with a compare value of a question mark. A compare value of ? indicates that the value for this filter will be specified on the event level, when this query is used within an event. The benefit of using the ? as a filter compare value is that it allows a single query to be used in multiple events. (E.g., this query could be used in one event that looks at orders shipped today, in another event that looks at orders shipped yesterday, and in a third event that looks at orders shipped last week.) Return to Tour Menu

55 Although KnowledgeSync automatically identifies whether a field contains character, date, or numeric data, you can change the way KnowledgeSync views that data to create even more flexible query filters. Return to Tour Menu

56 KnowledgeSync also provides the ability to group filters based on and/or relationships. Depending on the type of grouping you wish to do, you can accomplish it either via linear and/or logic, or you can simply insert parentheses around the filters you wish to group together. Return to Tour Menu

57 If you create filters whose value will be specified on the event level (i.e., filters with a compare value of ?), you can specify the prompt that will appear on the event level when a value needs to be supplied for this filter. When this query is used within an event, the user creating the event will be prompted to enter a selected product, a begin date range, and an end date range. Return to Tour Menu

58 The button at the lower right is what enables you to configure a query to check a field to see if its value has been changed. Return to Tour Menu

59 The fields listed on the left are those that can be monitored for a change to their value. Return to Tour Menu

60 The fields selected on the right are those that you have chosen to be monitored for changes to their value. Its worth noting that KnowledgeSync can not only determine when a field has had its value changed, but also determine when a field has had its value changed to one or more specific entries. Return to Tour Menu

61 The Sub Filters tab is used only with aggregate queries (such as testing for more than 6 orders shipped late last month. Since this is a record level query that uses no aggregate functions, this tab is left blank. Return to Tour Menu

62 Demo: Event Queries The SQL tab lets you see what KnowledgeSync is doing behind the scenes in this query. Without KnowledgeSyncs step-by-step Query Designer, this is what youd have to do manually to achieve the same results as the query. (And its also worth noting that the checkbox at the lower left of this window gives technical users the ability to directly edit the SQL syntax for this query, would they wish to do so.) Return to Tour Menu

63 Demo: Event Queries The Preview tab lets you test the results of your query. This is a very useful way of ensuring that your query retrieves only the records you want it to. This is the conclusion of the demonstration on how queries are created. Click here to go back to the Tour Menu and explore other aspects of Query Designing. Exit Presentation Return to Tour Menu

64 In KnowledgeSync, a single event may use multiple queries to identify complex conditions within a single application. Send an alert about any clients with more than $250,000 in historical sales and have at least one open sales opportunity of at least $30,000. For Example: Linked Queries Return to Tour Menu

65 Linked queries may also be used to create events that combine data across multiple applications. Send an alert about any clients with pending sales opportunities (in a CRM application) and are on credit hold (in a financial application). For Example: Cross Application Linked Queries Return to Tour Menu

66 Query #1: More Than $250,000 in Historical Sales... Query #2:... have a Pending Sale > $30,000 Query #1: Pending Sales (in a CRM App)... Query #2:... are on Credit Hold (in a Financial App) and When using multiple queries, the first step is to identify the conditions you wish to check for Clients With... Identify the Conditions Return to Tour Menu

67 Query #1: More Than $250,000 in Historical Sales Query #2: And Have a Pending Sale > $30,000 Query #1: Pending Sales (in a CRM App) Query #2: And Are on Credit Hold (in a Financial App) Contact.ClientID The second step is to identify the field (or fields) that link data from the two queries together Clients With... Account.AccountNo Identify Common Field(s) Return to Tour Menu

68 Condition: Clients With > $250,000 in Historical Sales and a Pending Sale >$30,000 Filter: Query #2 Contact.ClientID is the same as the Query #1 Contact.ClientID The final step is to create a filter in query #2 that links it to query #1 Condition: Clients With Pending Sales and on Credit Hold Filter: Query #2 Account.AccountNo is the same as the Query #1 Contact.ClientID Link Query #2 to Query #1 Return to Tour Menu

69 Heres an event that gets triggered if a client has a new sales opportunity created for them (in a CRM application) but happens to be on credit hold (in a financial application). The first step is to review the query that checks for new sales opportunities in the CRM application... Return to Tour Menu

70 The first query that we need to design is one that identifies clients with newly-created sales opportunities. Return to Tour Menu

71 This query retrieve all newly-created sales for each client. Because we will be using this query to feed information into a following query, we need to consider what field in this query will link to a field in the second query. In this example, we want to link clients in the CRM application with clients in the financial application. Thus we will use the ACCOUNT field as the linking field. (The linking field is always referenced by its Customized Name) You can use any field to link one query with another. Return to Tour Menu

72 Aside from making a note of the linking fields customized name, there is nothing special that we need to do in this first query. Return to Tour Menu

73 Our next step is to design the link to query – this is the one that will receive data from the first query and use that data as further selection criteria. Note that link to queries cannot be used alone; they are usable only when preceded by another query that feeds them the appropriate data. As a result, it is usually a good idea to identify a link to query by some unique text in its name. Return to Tour Menu

74 Like any other query, the link to query is designed to include the specific fields of data you require. Return to Tour Menu

75 Heres the key to the link to query: The first filter specifies that this query will retrieve only those clients on credit hold. The second filter specifies that this query will retrieve only those customers (on credit hold) who were also retrieved by the first (or preceding) query. And so, to link one query to another, all you need to do is: 1)Identify the two fields that link the queries together 2)Select the first field as a column in query #1 3)Select the second field as a filter in query #2 and compare it to the customized name of the linking field from query #1 (enclosed within {} symbols) Return to Tour Menu

76 There is one final step: choosing both the queries for a single event. One word of warning: Be sure to choose the queries in the right order. If the link to query is specified first, youll never get any matching records! Return to Tour Menu

77 Query Tables: You can select the same table multiple times. For example: You have a query that checks for activities created by one salesperson and assigned to another. You want to send an alert message that contains both the creators name and the assignees name. You choose the activity table and the salesrep table (the salesrep table contains the salesreps names.) You need to link from the activity table to the salesrep table twice; once to get the creators name and once to get the assignees name. However, ODBC does not allow you to link to the same table name twice. You need to use a table alias. In KnowledgeSync, you can select the same table name multiple times; after the first selection, KnowledgeSync will ask you to supply an alias name for the previously selected table. You may now do your links. Helpful Hints Return to Tour Menu

78 Query Links: 1.Order of Tables: A querys primary table must be the first listed in the Links tab. For example, a query that retrieves orders that are shipped late uses the orders, customers, and salesreps tables. As you specify your links, be sure that the orders table is the first table in the first link you create. 2.Optimizing Processing: If you have a choice as to the order of the tables you are using, select the tables that retrieve the fewest number of records first. This means that successive filters on other tables will go that much faster. 3.Manual Linking: If you need to manually specify the linking syntax, simply type in everything that would follow the word from in a SQL statement. Do not include the word from in your statement. 4.Overriding the Link Type: In general, dont do it unless youre sure of yourself or have spoken with Vineyardsoft support. Helpful Hints Return to Tour Menu

79 Query Columns: 1.Editing Selected Columns: Once you have selected a column, you can edit it within the grid. You can create columns that include arithmetic expressions, SQL expressions, or columns that are calculations of multiple fields. Simply click next to the selected column name and start typing. 2.Customized Names: Different databases (and ODBC sources) handle customized names slightly differently. It is suggested that you not embed blanks within customized names, and that you not make them overly long. 3.Multi-Field Uniques: KnowledgeSync allows only a single column to be selected as a unique. If you have a table that uses multiple columns as the unique value, you can create a column that concatenates these two fields into one – and then identify that field as the unique column. 4.Add All Columns to Query: This button is very handy if you dont know what data is stored in a tables fields. Simply select the table in question, click on the Add All Columns to Query button and click on the Preview tab. Helpful Hints Return to Tour Menu

80 Query Filters: 1.Editing Filter Columns: Probably the most powerful and little-known function within the Filters tab is the ability to edit a column once you have selected it for filtering. You can create filters that combine values from multiple fields, or that use SQL operators for even more sophisticated testing of conditions. 2.Checking for Blanks/Nulls: If you wish to check for a field value that is blank or null, you have two ways to do it. First, you can specify a filter using an operator of null. Secondly, you can specify a filter using an operator of is equal to and then place a blank space in the Compare Value field. 3.Date Ranges: If you would like to create a query that accepts a date range, it is suggested that you use two filters off of the same field (one filter testing date values greater than or equal to x and another filter testing date values of less than or equal to x). The following slides illustrate some of the more interesting filter conditions. Helpful Hints Return to Tour Menu

81 This query has a filter that uses an SQL operator to calculate the number of days between the current date and the date on which an order was placed. Return to Tour Menu

82 This query has a filter that adds the number of units of a product that are on order from a supplier to the number of units that are in stock and checks to see if that total is less than the products reorder (or minimum) stock level. Return to Tour Menu

83 And here is a query that subtracts the cost of a sale from the sale price and (thru a few other arithmetic functions) deduces the net profit percent. Note that by using the ? in the Compare Value fields, this one query can be used in many different events; each checking for a different percent range of net profit. Return to Tour Menu

84 Lastly, be aware that different databases (and ODBC drivers) support different operations and syntax in these query filters. If you have questions about what operators you can use in your filters, please contact the Vineyardsoft support team. Return to Tour Menu

85 The best way to proceed from here is to start building queries. 1.Focus on Query Designing: Dont worry about the events for now; build and preview a whole bunch of queries. Create record-level queries, aggregate queries, and queries that include more complex filters. Once you master query designing, the rest is a piece of cake! 2.Start Simple: You can always add tables, columns, and filters to a query. Start off by choosing just one table, a few columns, and one or two filters. Preview your results. If you like what you see, go on from there. 3.Use the Sample Database: If you dont have easy access to an ODBC-compliant database, use the KS_Sample.mdb that is included in the KnowledgeSync data directory. Its a mini-CRM database and is great for practice. 4.Dont Forget the Tutorials: KnowledgeSync includes tutorials (and pre-configured EventPaks) for the sample application, Sage MAS 90/200/500, Sage CRM SalesLogix, Microsoft Dynamics GP (Great Plains), Microsoft Dynamics CRM, and many other applications. Where to Go From Here Return to Tour Menu

86 Thank You Vineyardsoft Corporation 800-850-8055 www.vineyardsoft.com info@vineyardsoft.com Return to Tour Menu


Download ppt "Training Course #1: Query Designing Training Course #1: Query Designing Please view in slide show Page Down/Up or mouse click to navigate through the show."

Similar presentations


Ads by Google