NCR Trend SQL Query Generator (Pareto by Supplier, Part, Cause)
A Pareto of nonconformances by supplier, part or cause tells you where corrective action effort pays back. This generator writes a portable SQL query for it, using your own table and column names.
Fill in
Your table name; generic by design
NCR Pareto query
-- NCR Pareto by supplier_id, 2026-01-01 to 2026-09-30 -- Table and column names are generic. Replace with your schema. SELECT supplier_id AS category, COUNT(*) AS ncr_count, SUM(qty_rejected) AS total_qty_rejected, ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER (), 1) AS pct_of_total, ROUND(100.0 * SUM(COUNT(*)) OVER (ORDER BY COUNT(*) DESC ROWS UNBOUNDED PRECEDING) / SUM(COUNT(*)) OVER (), 1) AS cumulative_pct FROM quality_ncr WHERE ncr_date >= '2026-01-01' AND ncr_date <= '2026-09-30' GROUP BY supplier_id ORDER BY ncr_count DESC LIMIT 10;
Monthly trend variant
-- Monthly NCR count trend SELECT EXTRACT(YEAR FROM ncr_date) AS yr, EXTRACT(MONTH FROM ncr_date) AS mon, COUNT(*) AS ncr_count FROM quality_ncr WHERE ncr_date >= '2026-01-01' AND ncr_date <= '2026-09-30' GROUP BY EXTRACT(YEAR FROM ncr_date), EXTRACT(MONTH FROM ncr_date) ORDER BY yr, mon;
Syntax uses ANSI window functions with LIMIT, which works in PostgreSQL, MySQL 8 and similar. For SQL Server replace LIMIT with TOP, and for Oracle use FETCH FIRST. Table and column names are placeholders. Test on a copy and in read-only mode first.
Ask your quality data questions in plain language
Optional: we can show a read-only natural language layer over your NCR data.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter the name of your NCR table and the columns holding the date, the grouping field and the rejected quantity. Choose the date window and how many rows to return, then copy the SQL. The first block ranks categories by NCR count with a percent of total and cumulative percent, the numbers needed to draw a Pareto chart. The second block gives a monthly trend you can paste into a spreadsheet or BI tool.
Reading a Pareto result
Look at the cumulative percentage column. The few categories that reach about eighty percent of NCRs are your focus list. Rank by count first, then check quantity and cost, since a supplier with few NCRs but large scrap value may matter more. Trend the monthly block after a corrective action to see whether the count actually falls.
- Use consistent cause codes before trusting the chart
- Separate supplier, in-process and customer NCRs
- Review by value as well as count
Adapting to your ERP or QMS
ERP schemas vary widely. Quality modules in SAP, Oracle, Epicor or SyteLine each use their own table and field names, so this tool uses generic placeholders rather than guessing. Ask your administrator for the NCR header and detail tables, and join to the vendor and item masters if you want names instead of codes.
Common mistakes
Mixing closed and voided NCRs, counting an NCR once per line when you want one per record, and using free-text cause fields that cannot be grouped all distort the chart. Filter status deliberately and standardize cause codes.
Frequently Asked Questions
Will this run on my database as is?
Probably not without edits. Table and column names are placeholders, and window function and limit syntax vary by database. Adjust names and the row limit clause for your platform.
Does it need write access?
No. It is a read-only SELECT. Run it with a read-only account against a reporting copy where possible.
How do I get a Pareto chart?
Paste the result into Excel and chart the count as columns and the cumulative percent as a line on a secondary axis.
Why generic names?
Quality tables differ by ERP and version. Using made-up vendor-specific names would be misleading, so you map your own schema.
If NCR reporting is stuck in spreadsheets, we can discuss read-only queries or an AI assistant over your quality data on-premises.
Related Tools
Nonconformance (NCR) Cost Calculator
Add up the hidden labor, material, and escape costs behind your NCR volume and see what a realistic reduction program is worth annually.
Quality & InspectionAerospace Supplier Corrective Action Request Template
Issue a SCAR with defect details, required containment, root cause and effectiveness verification fields, then export to PDF or Word.
Aerospace & DefenseAerospace Material Review Board Disposition Template
Document an MRB decision with nonconformance details, engineering rationale, customer approval status and disposition, then export a PDF.
Aerospace & DefenseAerospace Lot Traceability Record JSON Generator
Builds a structured JSON record linking material heat, certificate, specification, work order and serial numbers for AS9100 traceability.
More Quality & Inspection tools
See all- AS9100 Internal Audit Report Template
- AS9145 APQP and PPAP Checklist
- Aerospace Key Characteristic Cpk Calculator
- AS9100 Risk and Opportunity Register Worksheet
- Aerospace Supplier OTD and Quality Rating Calculator
- AS9100 Management Review Minutes Template
- Aerospace Success-Run Sample Size Calculator
- Aerospace Test Uncertainty Ratio Calculator
- Aerospace Escaped Defect Containment Cost Calculator
Keep exploring
Free tools
- NCR Pareto and Repeat Offender SQL GeneratorFill in your NCR table and column names to get ready-to-run SQL for a defect Pareto with cumulative percent and a repeat offender list.
- NCR Pareto Chart Python Script GeneratorFill in your CSV file name and column headers to get a Python script that builds a Pareto chart of nonconformances from an ERP or QMS export.
- SAP Quality Notification Pareto SQL Query GeneratorBuild a SQL query over QMEL and QMFE that lists quality notifications and counts defects by code group and code, ready for a Pareto chart.
ERP fixes and how-tos
- How to query Infor Data Lake with Compass SQLHow to run a SQL query against Infor Data Lake with Compass: finding the right schema, filtering large BOD tables, and exporting the results safely.
- NetSuite Quality Management: Incoming Inspection and QuarantineNetSuite has no full QMS, but inventory status, workflows and custom records give incoming inspection, quarantine and NCR tracking. Setup steps and limits.
- How to Sync an NCR From Your QMS to ERP Quarantine and MRB DispositionHow to wire a QMS nonconformance report to ERP inventory holds and MRB dispositions: quarantine on open, post scrap, rework or RTV on close, with the pitfalls.
Guides
- AI-Powered Quality Management for SyteLineAutomate SyteLine quality management with AI. SPC analysis, NCR processing, CAPA management, and supplier quality for Infor CloudSuite Industrial.
- SyteLine Non-Conformance Report (NCR) Management ConfigurationConfigure SyteLine non-conformance report tracking and disposition workflows. Set up NCR creation, investigation, and resolution processes in CloudSuite Industrial.
- Natural Language Query Over ERP Data: What Actually WorksNatural language query over ERP data: how text-to-SQL, semantic layers, and RAG let SyteLine and Infor LN users ask questions and get trustworthy answers.
AI on your ERP
- AI for SyteLine Quality: Nonconformance Reports and Inspection DataAI for Infor SyteLine quality: analyse NCR trends, inspection results and supplier defects, draft dispositions for review, and keep quality data private on-prem.
- AI for NCR, CAPA, and 8D Drafting in AS9100 and ISO 9001 Quality SystemsAI drafts NCR, CAPA, and 8D reports from ERP quality data for engineer review, cutting drafting time under AS9100 and ISO 9001 without changing sign-off.
Integrations
- How to add AI agents to ProShop ERPHow to add AI agents to ProShop ERP: a tool layer over its API, agents for work order exceptions, NCR drafts and quote prep, with approval before any write.
- How to use Claude with ProShop ERPHow to use Claude with ProShop ERP: an MCP connector over the ProShop API, cloud hosting options via Bedrock or Vertex, data handling, and an on-prem alternative.