title_wip

We could also do both these steps in one go, using the `CREATE...AS` technique.
Let's create a different table using that technique:

```
sess.query(f"""
  CREATE TABLE youtube.dislikes2
  ORDER BY fetch_date 
  AS 
  SELECT * 
  FROM s3('{path}','JSONLines')
  SETTINGS schema_inference_make_columns_nullable=0
  """
)
```

## Querying a table[​](#querying-a-table "Direct link to Querying a table")

Finally, let's query the table:

```
df = sess.query("""
  SELECT uploader, sum(view_count) AS viewCount, sum(like_count) AS likeCount, sum(dislike_count) AS dislikeCount
  FROM youtube.dislikes
  GROUP BY ALL
  ORDER BY viewCount DESC
  LIMIT 10
  """,
  "DataFrame"
)
df
```

```
                             uploader  viewCount  likeCount  dislikeCount
0                             Jeremih  139066569     812602         37842
1                     TheKillersMusic  109313116     529361         11931
2  LetsGoMartin- Canciones Infantiles  104747788     236615        141467
3                    Xiaoying Cuisine   54458335    1031525         37049
4                                Adri   47404537     279033         36583
5                  Diana and Roma IND   43829341     182334        148740
6                      ChuChuTV Tamil   39244854     244614        213772
7                            Cheez-It   35342270        108            27
8                            Anime Uz   33375618    1270673         60013
9                    RC Cars OFF Road   31952962     101503         49489
```

Let's say we then add an extra column to the DataFrame to compute the ratio of likes to dislikes.
We could write the following code:

```
df["likeDislikeRatio"] = df["likeCount"] / df["dislikeCount"]
```

## Querying a Pandas dataframe[​](#querying-a-pandas-dataframe "Direct link to Querying a Pandas dataframe")

We can then query that DataFrame from chDB:

```
chdb.query(
  """
  SELECT uploader, likeDislikeRatio
  FROM Python(df)
  """,
  output_format="DataFrame"
)
```

```
                             uploader  likeDislikeRatio
0                             Jeremih         21.473548
1                     TheKillersMusic         44.368536
2  LetsGoMartin- Canciones Infantiles          1.672581
3                    Xiaoying Cuisine         27.842182
4                                Adri          7.627395
5                  Diana and Roma IND          1.225857
6                      ChuChuTV Tamil          1.144275
7                            Cheez-It          4.000000
8                            Anime Uz         21.173296
9                    RC Cars OFF Road          2.051021
```

You can also read more about querying Pandas DataFrames in the [Querying Pandas developer guide](/docs/chdb/guides/pandas).

## Next steps[​](#next-steps "Direct link to Next steps")

Hopefully, this guide has given you a good overview of chDB.
To learn more about how to use it, see the following developer guides:

- [Querying Pandas DataFrames](/docs/chdb/guides/pandas)
- [Querying Apache Arrow](/docs/chdb/guides/apache-arrow)
- [Using chDB in JupySQL](/docs/chdb/guides/jupysql)
- [Using chDB with an existing clickhouse-local database](/docs/chdb/guides/clickhouse-local)

- [Setup](#setup)- [Querying a JSON file in S3](#querying-a-json-file-in-s3)- [Configuring the output format](#configuring-the-output-format)- [Creating a table from JSON file](#creating-a-table-from-json-file)- [Querying a table](#querying-a-table)- [Querying a Pandas dataframe](#querying-a-pandas-dataframe)- [Next steps](#next-steps)

Was this page helpful?