# Unable to create a sales report using sql 2014 server script

**URL:** <https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884>\
**Category:** V5 Question\
**Created:** [March 27, 2023, 8:08am UTC](https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884 "2023-03-27T08:08:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nthiga](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/n/ce73a5/32.png) [@nthiga](https://forum.sambapos.com/u/nthiga)\
**Post date:** [March 27, 2023, 8:08am UTC](https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884/1 "2023-03-27T08:08:57Z")

</div>

Hi,  
Thanks for great work.  
I am generating a sales report by executing an sql script against SQL server 2014.  
One issue i am facing is not able to get correct sales report,  
how can i detect the correct sales data once

- item is sold?
- item is voided?
- item is cancelled?
- which database table stores what - where is sold item recorded or voided/cancelled item recorded  
I am using the Ticket Table and Orders table is there any other table i need to include?  
How can I tell with surety that an item is NOW sold and money is received?  
Could I can share the sql script i am currently using?  
You help is highly appreciated.  
David

---

<div class="post-metadata">

**Author:** ![Posflow](https://forum.sambapos.com/user_avatar/forum.sambapos.com/posflow/32/63001_2.png) [@Posflow](https://forum.sambapos.com/u/Posflow)\
**Post date:** [March 27, 2023, 12:52pm UTC](https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884/2 "2023-03-27T12:52:50Z")

</div>

Have a look at this, might get you started

> [@How to make Compare Report Sold, Gift, Void](https://forum.sambapos.com/t/how-to-make-compare-report-sold-gift-void/10807/2):
>
> You can use Pivot Table for that but you’ll need SQL to be able to bring data to the shape you need. SQL can also help us to pivot our data. I prepared a sample for you to give an idea. This is full custom report. You can modify that to fit to your needs. [Report:3, 1, 1, 1] \>Name|Sold|Gift|Void @{REPORT SQL DETAILS:Select distinct GroupCode as GroupCode from MenuItems:F.GroupCode::,} \>\>$1 {REPORT SQL DETAILS: Select GroupCode,MenuItemName,isnull(Sold,0) as Sold,isnull(Gift,0) as Gif…

---

<div class="post-metadata">

**Author:** ![nthiga](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/n/ce73a5/32.png) [@nthiga](https://forum.sambapos.com/u/nthiga)\
**Post date:** [April 3, 2023, 8:11am UTC](https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884/4 "2023-04-03T08:11:46Z")

</div>

Hello Linda,

Thanks for the input.

I will implement your advice

One more issue - how could i generate a inventory report -

We wish to have an inventory report showing

Inventory balance (Opening stock) | Inventory purchased | Inventory Sold | Current Inventory balance

in details - get the balance of soda by taking the balance as per yesterday evening - Inventory balance

Add purchases then less what we sold today the balance is the Days CLOSING Stock

You help will be appreciated.

David

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [April 3, 2023, 11:30am UTC](https://forum.sambapos.com/t/unable-to-create-a-sales-report-using-sql-2014-server-script/26884/5 "2023-04-03T11:30:03Z")

</div>

Hello several things that user said were false. I have flagged them and will watch but I’m not sure why they user is posting false info.
