# LS not reading jdbc input for large dataset. Order By Clause is a Issue in Microsoft SQL

**URL:** https://discuss.elastic.co/t/ls-not-reading-jdbc-input-for-large-dataset-order-by-clause-is-a-issue-in-microsoft-sql/276352
**Category:** Logstash
**Created:** [June 18, 2021, 8:27am UTC](https://discuss.elastic.co/t/ls-not-reading-jdbc-input-for-large-dataset-order-by-clause-is-a-issue-in-microsoft-sql/276352 "2021-06-18T08:27:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rkhapre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rkhapre/32/48333_2.png) [@rkhapre](https://discuss.elastic.co/u/rkhapre)
#### Post date: [June 18, 2021, 8:27am UTC](https://discuss.elastic.co/t/ls-not-reading-jdbc-input-for-large-dataset-order-by-clause-is-a-issue-in-microsoft-sql/276352/1 "2021-06-18T08:27:19Z")

</div>

Hi All

I know this question has been asked [earlier](https://discuss.elastic.co/t/why-i-am-getting-this-error-when-using-jdbc-input-plugin-of-logstash/237988) as well, but this issue is still there.  
But there was no clear statement on the [solution](https://discuss.elastic.co/t/why-i-am-getting-this-error-when-using-jdbc-input-plugin-of-logstash/237988/8), so i am asking again.  
**input** : jdbc-input-plugin  
**jdbc driver** : MSSQL  
Underneath jdbc input plugin uses this format/template

```auto
SELECT count(*) AS count FROM 
(
select .......
...........
) 
AS t1 LIMIT 1

```

When i use Order by query, it just utilizes the above template

```auto
SELECT count(*) AS count FROM 
(
select .......
...........
order by a.id asc
) 
AS t1 LIMIT 1

```

with this i get this error

> The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.

Now i cannot go and change the jdbc-input plugin template and get rid of that count. The count is also important because, i need to enable pagination

I do not need solution without pagination because i have millions on record, so pagination is necessary and to do that i need to do order by ascending.

Is there any other way to do ascending order?

But the above order by query works in other Databases, only MSSQL server is a problem

Thanks

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 16, 2021, 8:27am UTC](https://discuss.elastic.co/t/ls-not-reading-jdbc-input-for-large-dataset-order-by-clause-is-a-issue-in-microsoft-sql/276352/2 "2021-07-16T08:27:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
