How the VICIdial filter SQL fragment syntax works
A VICIdial filter is a SQL WHERE-clause fragment against the lead table — how to write one, what not to start it with, and worked examples.
The heart of a VICIdial Lead filter is the Filter SQL field. It is not a full query — it is a fragment, a single piece of a WHERE clause that the dialer slots into the lead lookup for you. Get the shape of that fragment right and the Filter does exactly what you mean.
It is a fragment, not a whole query
When the dialer pulls callable leads, it builds a SQL query against the lead table and tacks your fragment on as an extra condition. So you only write the condition — the part that would normally come after WHERE. The system supplies the surrounding query, including the joining word. You never write SELECT, you never name the table, and you never add the WHERE keyword yourself.
How the fragment slots in
flowchart LR
A[Base lead query] --> B[System adds AND]
B --> C[Your filter fragment]
C --> D[Final WHERE condition]
D --> E[Matching leads load into hopper]That flow is why the no-AND rule matters: the connecting word is already there. Your job is just the comparison. Once the combined condition runs, only the leads that satisfy it land in the Hopper for dialing, and everything else is skipped on this pull.
Worked examples
You combine conditions with AND and OR exactly as you would in any SQL WHERE clause. A few that work directly in the field:
- Call count window: called_count > 4 and called_count < 8 — only leads dialed between five and seven times.
- Specific counts: called_count IN('8','9','10','11') — only those exact call totals.
- Geography: state IN('NY','NJ') — only leads in New York or New Jersey.
- Status: status IN('NEW','CALLBK') — only leads at the Called status values you want to work.
- Freshness: entry_date > '2026-01-01' — only leads loaded since the start of the year.
You can chain them: state IN('CA') and called_count < 3 narrows to fresh California leads in one rule. Just remember each column name has to match a real field on the lead table, or the pull errors out. Quotes go around text and date values; bare numbers do not need them. Mixing AND and OR works too, but wrap your OR groups in parentheses so the logic reads the way you intend.
Always test before you enable
SQL is unforgiving — a stray quote, a wrong column, or an over-tight range can either error the pull or quietly return nothing. That is why the TEST ON CAMPAIGN form exists. After you write or change a fragment, run it against a Campaign and read the count. A healthy number means your rule is sound; a zero means tighten or loosen it before any agent feels it.
For how filters sit alongside scorecards, reviews, and the rest of your call-quality setup, the quality-control guide shows the whole picture, and the QC setup walkthrough covers the surrounding configuration.
VICIfast runs a managed VICIdial box where you can write and test filter SQL straight from the admin, live in under 40 seconds. See our plans and pricing.
About VICIfast LLC
VICIfast LLC operates a managed VICIdial hosting + BYOI service for outbound and inbound call centers. We run the dialers, the carriers, the recordings pipeline, and the compliance plumbing so operators don’t have to.
Citing this article
VICIfast Engineering. “How the VICIdial filter SQL fragment syntax works”. VICIfast LLC, June 26, 2026. Retrieved from https://vicifast.com/blog/vicidial-filter-sql-syntax-explained
Have questions?
Related posts
You might be interested in
VICIfast newsletter
Liked this? Get the next one in your inbox.
We ship the kind of stuff you just read — concrete, numbers-first, no drip. One email when a new post goes live. Unsubscribe in one click.
Comments
No comments yet — be the first.