Help Center/
CloudTable Service/
Developer Guide/
ClickHouse Application Development Guide/
Developing a ClickHouse Application/
Querying ClickHouse Data
Updated on 2025-07-25 GMT+08:00
Querying ClickHouse Data
Function Description
Query statement 1: querySql1 queries random 10 records in the tableName table.
Query statement 2: querySql2 uses a built-in function to obtain the year and month from the date field in the tableName table and then aggregate the data.
Sample Code
private void queryData(String databaseName, String tableName) throws Exception { String querySql1 = "select * from " + databaseName + "." + tableName + "_all" + " order by age limit 10"; String querySql2 = "select toYYYYMM(date),count(1) from " + databaseName + "." + tableName + "_all" + " group by toYYYYMM(date) order by count(1) DESC limit 10"; ArrayList<String> sqlList = new ArrayList<String>(); sqlList.add(querySql1); sqlList.add(querySql2); ArrayList<ArrayList<ArrayList<String>>> result = util.exeSql(sqlList); for (ArrayList<ArrayList<String>> singleResult : result) { for (ArrayList<String> strings : singleResult) { StringBuilder stringBuilder = new StringBuilder(); for (String string : strings) { stringBuilder.append(string).append("\t"); } log.info(stringBuilder.toString()); } } }
Parent topic: Developing a ClickHouse Application
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot