# SQL

**URL:** https://community.cratedb.com/c/cratedb/sql/19.md?page=3

[Latest](https://community.cratedb.com/latest.md) · [Categories](https://community.cratedb.com/categories.md) · [Tags](https://community.cratedb.com/tags.md)

**Page:** 4

---

## [Alter a table created on an older version](https://community.cratedb.com/t/alter-a-table-created-on-an-older-version/265)

<div class="topic-metadata">

**Author:** [@Deepak\_Sen](https://community.cratedb.com/u/Deepak_Sen)\
**Replies:** 1\
**Last updated:** [August 14, 2019, 2:19pm UTC](https://community.cratedb.com/t/alter-a-table-created-on-an-older-version/265 "2019-08-14T14:19:03Z")

</div>

created a table in version 1.0.2 upgraded crate to 1.1.3 upgraded crate d to 2.1.6 now when i alter a table using below command alter table gra.testtable add column attributes\[‘testing’\] STRING; i get below error S…

---

## [SQL parser detect alias as table column](https://community.cratedb.com/t/sql-parser-detect-alias-as-table-column/259)

<div class="topic-metadata">

**Author:** [@gorhome](https://community.cratedb.com/u/gorhome)\
**Replies:** 2\
**Last updated:** [August 6, 2019, 9:55am UTC](https://community.cratedb.com/t/sql-parser-detect-alias-as-table-column/259 "2019-08-06T09:55:35Z")

</div>

Hi guys, Have some strange error when I tried to execute the next SELECT query: SELECT count(a.id) count\_yes, a.stepid stepid\_yes, a.stepid FROM activity a WHERE …

---

## [Why Crate Sql is slower than elasticsearch http API](https://community.cratedb.com/t/why-crate-sql-is-slower-than-elasticsearch-http-api/244)

<div class="topic-metadata">

**Author:** [@sunny](https://community.cratedb.com/u/sunny)\
**Replies:** 1\
**Last updated:** [July 30, 2019, 8:29am UTC](https://community.cratedb.com/t/why-crate-sql-is-slower-than-elasticsearch-http-api/244 "2019-07-30T08:29:11Z")

</div>

I am testing the crateDB performance. There are 78164052 docs in CrateDB on 1 node server. select “year”,count(hotel\_code) as count from f\_and\_b group by “year” limit 100; will take SELECT OK, 18 rows in set (6.020 …

---

## [CrateDB LEFT JOIN performance](https://community.cratedb.com/t/cratedb-left-join-performance/209)

<div class="topic-metadata">

**Author:** [@metase](https://community.cratedb.com/u/metase)\
**Replies:** 0\
**Last updated:** [May 23, 2019, 11:35pm UTC](https://community.cratedb.com/t/cratedb-left-join-performance/209 "2019-05-23T23:35:26Z")

</div>

I’m trying to “debug” an issue where LEFT join seems to be taking unprecedentedly long to complete. Following on from Crate’s documentation on how to write joins (and the usual SQL) I wanted to join two tables and find o…

---

## [Full text searching by multiple columns with some columns having weight only if they match](https://community.cratedb.com/t/full-text-searching-by-multiple-columns-with-some-columns-having-weight-only-if-they-match/204)

<div class="topic-metadata">

**Author:** [@scott\_roofstock.com](https://community.cratedb.com/u/scott_roofstock.com)\
**Replies:** 0\
**Last updated:** [May 17, 2019, 10:49pm UTC](https://community.cratedb.com/t/full-text-searching-by-multiple-columns-with-some-columns-having-weight-only-if-they-match/204 "2019-05-17T22:49:22Z")

</div>

I’m trying to match addresses in a table using full text indexes. I’m having trouble with the CITY column. CITY names are often vanity names. For example, the city of Los Angeles has a city referred to as “Hollywood.”…

---

## [Calculate End date of current, previous or next month](https://community.cratedb.com/t/calculate-end-date-of-current-previous-or-next-month/195)

<div class="topic-metadata">

**Author:** [@ritwick](https://community.cratedb.com/u/ritwick)\
**Replies:** 1\
**Last updated:** [May 3, 2019, 12:24pm UTC](https://community.cratedb.com/t/calculate-end-date-of-current-previous-or-next-month/195 "2019-05-03T12:24:03Z")

</div>

Hi Based on the current date I would like figure out what is the end date of the previous, current or the next month. Is it possible using scalar or other means in CrateDB? Thanks, Ritwick

---

## [Error with "Copy to"](https://community.cratedb.com/t/error-with-copy-to/50)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 3\
**Last updated:** [February 20, 2019, 9:37am UTC](https://community.cratedb.com/t/error-with-copy-to/50 "2019-02-20T09:37:35Z")

</div>

Hi I am receiving thie error when doing COPY TO with crate command: crash --hosts 127.0.0.1 -c “copy metermaster22 to DIRECTORY ‘/crateBackup’” CONNECT OK SQLActionException\[NotSerializableExceptionWrapper: unhandled…

---

## [How to clear query cache?](https://community.cratedb.com/t/how-to-clear-query-cache/140)

<div class="topic-metadata">

**Author:** [@chughpiyush](https://community.cratedb.com/u/chughpiyush)\
**Replies:** 1\
**Last updated:** [February 5, 2019, 3:41pm UTC](https://community.cratedb.com/t/how-to-clear-query-cache/140 "2019-02-05T15:41:42Z")

</div>

So elastic search provides some queries that can clear the cache associated with one or more indices. Do we have such a query in CrateDB as well? https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-…

---

## [Number of shards cannot be increased](https://community.cratedb.com/t/number-of-shards-cannot-be-increased/129)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 1\
**Last updated:** [January 24, 2019, 11:21am UTC](https://community.cratedb.com/t/number-of-shards-cannot-be-increased/129 "2019-01-24T11:21:16Z")

</div>

Hey! I can’t seems to increase number of shards (from your docs) SQLActionException: 400 Bad Request 4000 SQLParseException: Invalid property “number\_of\_shards” passed to \[ALTER | CREATE\] TABLE statement at io.crate.ex…

---

## [LEFT and RIGHT JOINS reverse behavior for some tables](https://community.cratedb.com/t/left-and-right-joins-reverse-behavior-for-some-tables/112)

<div class="topic-metadata">

**Author:** [@bpiel](https://community.cratedb.com/u/bpiel)\
**Replies:** 1\
**Last updated:** [January 23, 2019, 5:51am UTC](https://community.cratedb.com/t/left-and-right-joins-reverse-behavior-for-some-tables/112 "2019-01-23T05:51:40Z")

</div>

It seems like the behavior of LEFT vs RIGHT JOINS can flip, depending on which tables I’m querying. Any idea what’s going on? thanks cr\> select "test1"."id" "a", "test2"."id" "b" from "test1" left join "test2" on 1=2; …

---

## [Multiplying INT columns with DECIMALS results in INT results](https://community.cratedb.com/t/multiplying-int-columns-with-decimals-results-in-int-results/95)

<div class="topic-metadata">

**Author:** [@Dominik](https://community.cratedb.com/u/Dominik)\
**Replies:** 1\
**Last updated:** [January 10, 2019, 9:07am UTC](https://community.cratedb.com/t/multiplying-int-columns-with-decimals-results-in-int-results/95 "2019-01-10T09:07:34Z")

</div>

Observation: When we multiply using values - SELECT 1 / (10\*1.0 - 5\*1.0) the return value is a fraction. If however we use integer fields of a CrateDB table instead of fixed values, the return value is an INT but it sho…

---

## [String function for lower case?](https://community.cratedb.com/t/string-function-for-lower-case/85)

<div class="topic-metadata">

**Author:** [@yash](https://community.cratedb.com/u/yash)\
**Replies:** 1\
**Last updated:** [December 7, 2018, 5:17pm UTC](https://community.cratedb.com/t/string-function-for-lower-case/85 "2018-12-07T17:17:16Z")

</div>

Hi, Could somebody tell me if there is an equivalent of the LOWER() function for string arrays? Thanks.

---

## [Aggregation Query](https://community.cratedb.com/t/aggregation-query/80)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 0\
**Last updated:** [December 5, 2018, 8:38am UTC](https://community.cratedb.com/t/aggregation-query/80 "2018-12-05T08:38:38Z")

</div>

Hi All, iam doing a aggregation query insert into another table. Now when the id is duplicate i set the value to overwrite with: on conflict (id) do update set val\_average = val\_average, val\_count = val\_count, val\_ma…

---

## [Any alternative of CASES keyword in Crate?](https://community.cratedb.com/t/any-alternative-of-cases-keyword-in-crate/71)

<div class="topic-metadata">

**Author:** [@yash](https://community.cratedb.com/u/yash)\
**Replies:** 1\
**Last updated:** [November 27, 2018, 2:43pm UTC](https://community.cratedb.com/t/any-alternative-of-cases-keyword-in-crate/71 "2018-11-27T14:43:03Z")

</div>

Need alternative of CASES in Crate? For e.g. (case when user\_role = ‘student’ then ‘622057’ when user\_role = ‘assistant’ then ‘2913659’ when user\_role = ‘admin’ then ‘6160230’ end), Need to update certain fields wi…

---

## [COPY TO SYNTAX help](https://community.cratedb.com/t/copy-to-syntax-help/45)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 0\
**Last updated:** [October 22, 2018, 9:52am UTC](https://community.cratedb.com/t/copy-to-syntax-help/45 "2018-10-22T09:52:12Z")

</div>

Hi I am receiving thie error when doing COPY TO with crate command: ​ crash --hosts 127.0.0.1 -c “copy metermaster22 to DIRECTORY ‘/crateBackup’” CONNECT OK SQLActionException\[NotSerializableExceptionWrapper: unhandl…

---

## [Column Id Unknown](https://community.cratedb.com/t/column-id-unknown/53)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 1\
**Last updated:** [November 6, 2018, 2:51pm UTC](https://community.cratedb.com/t/column-id-unknown/53 "2018-11-06T14:51:23Z")

</div>

I’ve tried a lot of syntax combinations, but always got “column \_id unknown” or similar error The following is a sample query: CREATE TABLE IF NOT EXISTS “doc”.“test1” ( “col1” STRING, “col2” INTEGER, primary key …

---

## [Bulk Insert by Rest or PostgreSQL](https://community.cratedb.com/t/bulk-insert-by-rest-or-postgresql/51)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 1\
**Last updated:** [November 6, 2018, 2:45pm UTC](https://community.cratedb.com/t/bulk-insert-by-rest-or-postgresql/51 "2018-11-06T14:45:54Z")

</div>

Hi ! Does anyone know bulk insert supported only by Rest protocol or also by PostgreSQL wire protocol? Documentation only admits about http… :nachdenklich:

---

## [Ist there a way to use aggregation function in an array column?](https://community.cratedb.com/t/ist-there-a-way-to-use-aggregation-function-in-an-array-column/46)

<div class="topic-metadata">

**Author:** [@roman](https://community.cratedb.com/u/roman)\
**Replies:** 1\
**Last updated:** [October 22, 2018, 9:54am UTC](https://community.cratedb.com/t/ist-there-a-way-to-use-aggregation-function-in-an-array-column/46 "2018-10-22T09:54:39Z")

</div>

Ist there a way to use aggregation function in an array column?

[Previous page](https://community.cratedb.com/c/cratedb/sql/19.md?page=2)
