home

Indirect Tax

Sovos Docs

Query the Snowflake database

Follow these steps to get Global Tax Determination data directly from the Snowflake database.

To pull your data from the database, run a query in a SQL worksheet. You can edit a sample query of an existing Global Tax Determination Cloud report or write your own query.

Transactional data in Global Tax Determination Cloud is stored in the Lines by Jurisdiction (LBJ) table, referenced as lbj_share_view_with_policy in Snowflake. The fields in this table are explained in the LBJ data dictionary.

Tip: There are 363 fields in the Lines by Jurisdiction table, not all of which are relevant to your organization. Read the field descriptions in the data dictionary to make sure that you are pulling the data you need.
  1. Enter the link, username, and password in a new window and log in to Snowflake.
    This information is provided provided by Professional Services during the implementation phase.
  2. Take one of the following steps:
    • Download and edit sample queries of the following Sovos reports: Simplified Transaction Detail Report, Transaction Report by Line Item, Transaction Report by Line Item and Taxing Jurisdiction.
      1. Go to Projects > Worksheets.

      2. On the main screen, click the Download icon, then select SQL Worksheet.

      3. Make sure that your user role is either SYSADMIN or ACCOUNTADMIN and that the correct warehouse is selected.

      4. Copy the text of the sample query and paste it into the SQL worksheet.

      5. Follow the instructions included in the sample query to set the variables and execute the query.

      6. After you have successfully queried the database, the query results will appear in the Results section. To download the data, click the Download results icon, then select a format.

      7. The results will be downloaded to your computer. The file will have the same name as the SQL worksheet.

    • Write your own queries.
      • If modifying one of the Global Tax Determination Cloud reports does not give you the data you need, you can create a custom query. Snowflake offers extensive SQL support to manipulate data beyond what is possible in Global Tax Determination Cloud reports.
      • The following table includes some short example queries that show how you might pull, filter, and order data. You can also check the Reference section of the Snowflake documentation for supported SQL commands and functions.
      • When you have written your query, follow the instructions in the previous step option, Download and edit sample queries, to query the database, using your custom query instead of the sample.
        TaskQuery
        Pull a list of 100 document numbers
        select distinct(transaction_document_number)from lbj_share_view_with_policygroup by transaction_document_numberlimit 100;
        Find transactions with a specific document number
        select from lbj_share_view_with_policywhere transaction_document_number = '0689815962';
        Query the line item audit ID, taxing jurisdiction, document tax amount, line item tax amount, taxing jurisdiction-level tax amount, gross amount, and tax rate for a specific document, state, and invoice date range
        select line_item_audit_id, tj_type,  document_tax_amount,line_item_tax_amount, line_tj_result_tax_amount,gross_amount, tax_rate from lbj_share_view_with_policy where transaction_document_dateBETWEEN TO_DATE('2020-06-01', 'YYYY-MM-DD')AND TO_DATE('2020-06-30', 'YYYY-MM-DD')and ship_to_tjc_state = 'ILLINOIS'and document_audit_id = 'e6f6054e-5c7e-465a-b5c5-4ac840a78078';limit 5;
        Find cities with transactions in a specific state
        select distinct(ship_to_tjc_city), count(1)from lbj_share_view_with_policy where ship_to_tjc_state = 'ILLINOIS'group by ship_to_tjc_cityorder by count(1) desc;