# ZINCRBY

> Add to the score of a member of a sorted set.

URL: https://docs.hotkv.com/commands/zincrby/

```
ZINCRBY key increment member
```

- Group: Sorted set
- Complexity: O(log(N)) where N is the size of the sorted set
- HotKV Cloud: all plans
- On-Premise: no license needed

`ZINCRBY` adds `increment` to the score of `member` in the sorted set at `key`
and returns the new score. A missing member is added with `increment` as its
score, and a missing key is created. Use a negative increment to subtract.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Bulk string: the new score | Double: the new score |

Errors:

- `WRONGTYPE` if `key` holds a value that is not a sorted set.
- `ERR value is not a valid float` if `increment` is not a number.
- `ERR resulting score is not a number (NaN)` if the sum would be NaN (for
  example adding `-inf` to a score of `inf`). Nothing changes in that case.

## Examples

```
127.0.0.1:6379> ZADD board 100 "alice"
(integer) 1
127.0.0.1:6379> ZINCRBY board 15 "alice"
"115"
127.0.0.1:6379> ZINCRBY board -2.5 "bob"
"-2.5"
```

## Compatibility

Same replies as Redis 7.4 and Valkey 8. HotKV checks the key's type before the
increment, so a bad increment on a key of another type replies `WRONGTYPE`
rather than the float error.

## See also

[ZADD](https://docs.hotkv.com/commands/zadd/index.md), [ZSCORE](https://docs.hotkv.com/commands/zscore/index.md), [HINCRBYFLOAT](https://docs.hotkv.com/commands/hincrbyfloat/index.md)