Question: I am setting up a Serverless application for a system and I am wondering the following:

Say that my table handle Companies. Each Company can have Invoices. Each company has roughly 6-8000 Invoices. Say that I have 14 Companies, that results in roughly 112 000 items in my table.

Is it "okay" to handle it this way? I will only pay for each Get request I do, and I can query a lot of items into the same get request.

* I will not fetch every single item each time I write or get items.

So, is there a recommendation for how many items I should max have in a table? I could bake some items together, but I mainly want a general recommendation.

Answer: 
Try this:

```
SELECT *
FROM [Input]
WHERE ID IN (
    SELECT ID FROM [Input] GROUP BY ID HAVING COUNT(ID) = 1
)

```
You can use **SQL Common Transaction Expression** ([CTE](https://learn.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql?view=sql-server-ver15)) AS FOLLOWS

```
declare @mytable as table(id int ,name nvarchar(100),age int,location nvarchar(50))

insert into @mytable values
(1,'a',22,'usa'),(1,'a',23,'usa'),(2,'b',44,'uk'),(3,'e',33,'eu'),(3,'f',55,'Tunisia'),('8','k',49,'Palestine')

with 
cte1 as(select * from @mytable),
cte2 as (select id, count(1) N from @mytable group by id),
cte3 as (select TA.id,TA.name,TA.age,TA.location from cte1 TA inner join cte2 TB on TA.id=TB.id where TB.N=1)
select * from cte3

```