NetSuiteFree generatorPDF, Excel, Word exportNetSuite

SuiteQL Query Generator for NetSuite

SuiteQL lets you read NetSuite data with SQL instead of building saved searches in code. This generator assembles a clean statement from the pieces you fill in, so you can paste it into a script, a REST call or a test harness.

Fill in

Record table name followed by an alias, for example transaction t or customer c.

Wrap list or record fields in BUILTIN.DF() to return the display name instead of the internal ID.

Generated code
Download:

SuiteQL statement

SELECT
  t.id, t.tranid, t.trandate, BUILTIN.DF(t.entity) AS customer, t.foreigntotal
FROM
  transaction t
WHERE
  t.type = 'SalesOrd' AND t.trandate >= TO_DATE('2026-01-01', 'YYYY-MM-DD')
ORDER BY
  t.trandate DESC
FETCH FIRST 100 ROWS ONLY

Same statement as a single line for REST or a script string

SELECT t.id, t.tranid, t.trandate, BUILTIN.DF(t.entity) AS customer, t.foreigntotal FROM transaction t WHERE t.type = 'SalesOrd' AND t.trandate >= TO_DATE('2026-01-01', 'YYYY-MM-DD') ORDER BY t.trandate DESC FETCH FIRST 100 ROWS ONLY

Where to run it

-- SuiteScript 2.x: query.runSuiteQL({ query: sql, params: [] }).asMappedResults()
-- REST: POST /services/rest/query/v1/suiteql?limit=1000 with header Prefer: transient and body { "q": "<statement>" }
-- UI: Analytics > SuiteAnalytics Workbook is not SuiteQL, use a SuiteQL console bundle or the N/query module

SuiteQL is Oracle-flavored SQL over the NetSuite analytics data source. Table and column names come from the Records Catalog in your account (Setup > Records Catalog, or the Analytics Browser). Available columns depend on role permissions and enabled features, so verify names in your account and sandbox before shipping a script.

Ask NetSuite in plain language

See how ERPray turns a business question into a read-only query over your NetSuite data, with the SQL shown.

Optional. The tool and every export work without this. No spam.

How to use the generator

Enter the table with an alias, list the columns, write the filter and pick a sort. The statement updates as you type, and a single-line copy is provided for pasting into a JavaScript string or a REST body. The default example reads sales orders from 2026 onward and shows the customer name using BUILTIN.DF. Change the type code and date to match your case, then run it in a sandbox first.

  • Always alias the table and prefix columns with the alias
  • Use TO_DATE with an explicit format for date filters
  • Use FETCH FIRST n ROWS ONLY to cap result size while testing
  • Quote string literals with single quotes

SuiteQL behavior worth knowing

SuiteQL follows Oracle SQL syntax, so row limits use FETCH FIRST or ROWNUM rather than LIMIT. BUILTIN.DF returns the display value of a list or record field and BUILTIN.CF returns the value in the consolidated currency context. Transaction lines live in transactionline joined on the transaction ID, and transaction type codes such as SalesOrd, PurchOrd, CustInvc and VendBill are stored in the type column. Results from the REST endpoint are paged, with a default and a maximum page size of 1000 rows.

Reading the output

Mapped results from N/query return objects keyed by column name or alias, so give every computed column an alias. When a column is a NetSuite internal ID, the value comes back as a number or string depending on the field, so compare carefully in JavaScript. For large exports, page through results with offset in REST or use the paged query API in N/query instead of one big fetch, which keeps governance usage and memory predictable.

Common mistakes

Most failures come from a column name that exists in the UI but not in the analytics schema, a join to transactionline without the transaction filter, and missing BUILTIN.DF so reports show IDs. Another is assuming the query sees records the role cannot see: SuiteQL respects role permissions, and a script running as a restricted role returns fewer rows than an administrator.

  • Check column names in the Records Catalog before use
  • Filter transactionline by mainline or the parent transaction
  • Test with the same role the script will run under
  • Do not build SQL by concatenating user input, pass params instead

Frequently Asked Questions

Is SuiteQL the same as SQL?

It is Oracle-style SQL for reading NetSuite data. It supports select, joins, grouping and functions, but it is read-only and uses NetSuite table and column names. Writes still go through record APIs, not SuiteQL statements.

How do I limit rows in SuiteQL?

Use FETCH FIRST n ROWS ONLY at the end of the statement, or filter on ROWNUM in a subquery. LIMIT is not supported. In REST you can also pass limit and offset query parameters to page through results.

Why do I get IDs instead of names?

List and record fields return internal IDs by default. Wrap the column in BUILTIN.DF(column) to return the display value, and give it an alias so the result key is readable in your script.

Can SuiteQL replace saved searches?

For many read cases yes, especially joins and aggregates that are awkward in searches. Saved searches still have features SuiteQL lacks, such as some formula and summary behaviors, so check the result against an existing search before replacing it.

If your team writes a lot of SuiteQL for reporting questions, ERPray can answer those questions in plain language over NetSuite data, showing the query it ran and respecting NetSuite roles.