# Data Querying

> Write and verify SQL queries with BigQuery. Use when executing bq commands, writing SQL queries, or including query results in documents.

- Skill: `majiayu000/data-querying` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/data-querying`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/data-querying/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/data-querying

---


# Data Querying

## Verification Requirement

All queries MUST be executed with `bq` and verified before inclusion. Never include unverified queries or fabricated data.

## Query Process

1. **Dry run**: Validate syntax and check cost

   ```bash
   bq query --project_id=<PROJECT_ID> --use_legacy_sql=false --dry_run "SELECT ..."
   ```

   Cost: ~$5/TB. <1GB is light, 2GB+ needs optimization.

2. **Execute**: Run and confirm results

   ```bash
   bq query --project_id=<PROJECT_ID> --use_legacy_sql=false --format=csv "SELECT ..."
   ```

3. **Learn**: Study existing queries in project docs for patterns.

## Query Design

- Specify exact date ranges
- Filter partitioned tables by partition key
- Avoid correlated subqueries (use JOINs/CTEs)
- Filter early with CTEs before joining large tables

## Documentation

1. Execute exact query with `bq`
2. Copy real output only
3. State time period and what query measures

