Filtered Rows

In a data inspection context, we typically filter rows by column values to get a sense of the data e.g. to check for surprising values. We cover the basics of filtering here and in detail in Filtering.

Filter

We wish to extract rows that meet a certain condition on column values. In this example, we filter out rows where the column col_6 has a value of 0.

SELECT *
FROM refcon.dataset.table_1
WHERE col_6 = 0;

Here is how this works:

  • We use WHERE for filtering rows by a boolean condition on column values.
  • In this case, we compare the value of col_6 with the integer 0 and return only the rows where the condition evaluates to TRUE.

Selected Columns

We wish to extract rows that meet a certain condition on column values. We wish to return only a specified set of columns (and not all columns). This is useful while developing a filter to look at just the relevant columns to verify if the filtering works as expected.

In this example, we wish to return rows where the value of col_6 is greater than 0 and to return columns col_1 and col_6.

SELECT col_1, col_6
FROM refcon.dataset.table_1
WHERE col_6 = 0;

Here is how this works:

  • We use specify the column names we wish to include in the output after the SELECT keyword. In this example, the column names are col_1 and col_6. For detailed coverage, see Selecting by Name.
  • We use WHERE for filtering rows by a boolean condition on column values.
SQL
I/O