This topic explains how to create and edit an SQL query in dbForge Fusion for SQL Server using the Query Builder features.
We are going to create a sample query by using visual query designer. We will use the AdventureWorks2012 database. Assume we need to display all the employees whose total sales result for the preceding year is greater than 2 000 000.
Create a server connection. For more information about how to create a server connection, see Connect to a Database.
On the Fusion menu, click New Query.
Drag-and-drop required tables from Database Explorer to the editor. Holding CTRL, select the Person table and the SalesPerson table, and drag-and-drop them over to the visual editor.
Select the FirstName and LastName checkboxes in the Person table, and the SalesLastYear checkbox in the SalesPerson table.
Create a relationship between tables based on the BusinessEntityID primary key. To do this, select BusinessEntityID in the Person table and drag it over the BusinessEntityID in the SalesPerson table.
On the Where tab, insert the condition. Click the green plus icon.
Click enter value. In the Table drop-down list, select the SalesPerson table, and then select the SalesLastYear column.
Click the equals sign and select greater than instead.
Click enter value and type 2 000 000.
On the Group By tab, select columns you want to group by the output data.
On the Order By tab, select the sort order.
Finally, the visual query will look as follows:
Press F5 to execute the query.
You can also view and edit (if needed) the generated automatically SQL code.
In this topic we reviewed a quite simple query, however, it demonstrates the convenience of the approach on creating queries visually.
Visual query editor will save a lot of your time in case of more complex queries to multiple tables and views.