# In accurate data

**URL:** <https://forum.codewithmosh.com/t/in-accurate-data/2170>\
**Category:** SQL\
**Created:** [January 22, 2021, 12:52am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170 "2021-01-22T00:52:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 22, 2021, 12:52am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/1 "2021-01-22T00:52:24Z")

</div>

I’m currently on the Aggrevate Functions Exercise and my results are not same under my “total\_payments” and “what\_we\_expect” column. I restored the databases as instructed yet not all of my numbers the same. Did Mosh recently upload different sql files? Is any one else experiencing the same thing?

Here’s my results:

![aggrevate](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/6af7b252baaaaed6d9b18e64663b1693d3a155ff.png)

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 22, 2021, 1:49pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/2 "2021-01-22T13:49:15Z")

</div>

That’s interesting 🧐.

I made the query again, and I got different values than Mosh’s… and yours!! Anyway, if you add total\_payments and what\_to\_expect, you get the total\_sales… which in my query and Mosh’s agree… but not yours. double check the what\_to\_expect column query… something may be wrong in that SUM().

 ![Captura de Pantalla 2021-01-22 a la(s) 8.38.18 a. m.](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/dca1226ebc1018696b679df654369c2a3caefec9.jpeg)

I made a quick query, to check the values of the whole 2019 year. Use these values to check your table:

 ![Captura de Pantalla 2021-01-22 a la(s) 8.42.06 a. m.](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/421462eca63bc52a510ee3b867b8c1f326b35de2.jpeg)

I’ve had some differences between my results and Mosh’s, but what I really care is that the queries are well written.

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 22, 2021, 6:55pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/3 "2021-01-22T18:55:27Z")

</div>

Hi @NicolasATC,

My invoice data is the exact same as yours, and the only thing that was different about my query is “(invoice\_total - payment\_total) AS what\_we\_expect” without the SUM function. I get the same results with or without it.

Is there anything else you suggest? If not, I guess I’ll continue this course as is, but it is gonna be a little frustrating getting different results.

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 22, 2021, 7:07pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/4 "2021-01-22T19:07:30Z")

</div>

Would you mind sharing an screeshot of your code and the result?? just like I did in my screenshots. Maybe an addional pair of eyes can help you find the error.

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 22, 2021, 7:30pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/5 "2021-01-22T19:30:04Z")

</div>

Here you go:

![first](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/9378be96fcb8c03ab7c02a1bdece615ec81a6a7e.png)

![second](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/744f046c87aa4ce73a0d1b987be42f61e036c55b.png)!

![third](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/6822d3a9ae0220ad5da496e31242f5b5f571c90b.png)

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 22, 2021, 7:35pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/6 "2021-01-22T19:35:40Z")

</div>

I only found 2 differences… and those 2 make a big difference in the results.

You wrote:  
`WHERE invoice_date BETWEEN '2019-07-01' AND '2019-12-30'`

And it should include June 30th… and December 31st. So change the dates to:

`WHERE invoice_date BETWEEN '2019-06-30' AND '2019-12-31'`

I’m not sure if this is enough for the results to match, but if they don’t, I suggest you create another server download everything again and redo all the database.

Let me know how it goes.

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 22, 2021, 7:50pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/7 "2021-01-22T19:50:28Z")

</div>

![results](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/b33bfd0e7fd3a15b5eefb94ed6abe4d52d7b612a.png)

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 22, 2021, 7:56pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/8 "2021-01-22T19:56:05Z")

</div>

Cool… we have a match in data. 😃 I’m using your same code I have the same results

 ![Captura de Pantalla 2021-01-22 a la(s) 2.51.50 p. m.](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/32637eefea2ec193ac640fea31366ccfe0fc4178.jpeg)

Now, consider changing the dates… according to my last post. And again. Post picture of the query and the results. In this query, I’m including JUne 30 and December 31:

 ![Captura de Pantalla 2021-01-22 a la(s) 2.55.04 p. m.](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/b384b4e0a275702b2773865be2b495a7e21bd8e3.jpeg)

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 22, 2021, 9:26pm UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/9 "2021-01-22T21:26:06Z")

</div>

Here they are:

![new_query](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/161ebbab0ba9f561a7ad860a20551e6e3bf5869a.png)

![second_new_query](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/c3b981b33f55d0df6434dffac3f2b56319a3b1f3.png)

---

<div class="post-metadata">

**Author:** ![pfabbi](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@pfabbi](https://forum.codewithmosh.com/u/pfabbi)\
**Post date:** [January 23, 2021, 12:26am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/10 "2021-01-23T00:26:30Z")

</div>

Okay I will, thanks for your help.

---

<div class="post-metadata">

**Author:** ![NicolasATC](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/nicolasatc/32/714_2.png) [@NicolasATC](https://forum.codewithmosh.com/u/NicolasATC)\
**Post date:** [January 23, 2021, 1:40am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/11 "2021-01-23T01:40:46Z")

</div>

It seems we have the same data … weird that my data doesn’t match Mosh’s… but that’s ok for me. I think that designing courses is not an easy task.

I’m glad I could help you to figure it out.

---

<div class="post-metadata">

**Author:** ![lucidlear](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/lucidlear/32/5477_2.png) [@lucidlear](https://forum.codewithmosh.com/u/lucidlear)\
**Post date:** [June 9, 2023, 6:23am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/12 "2023-06-09T06:23:18Z")

</div>

Anyone else getting different results to Mosh for this exercise? I restored the db and everything but I got the below results, similar to others in this thread. Used the same code as Mosh

![sql](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/8/84cc7dd80b90f4fda86ad928914e7c249cdf3b8f.png)

---

<div class="post-metadata">

**Author:** ![raamz909](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@raamz909](https://forum.codewithmosh.com/u/raamz909)\
**Post date:** [November 25, 2024, 6:24am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/13 "2024-11-25T06:24:18Z")

</div>

hello i get almost the same data as you ````

| range\_date | total\_sales | total\_payments | what\_we\_expect |
| --- | --- | --- | --- |
| total | 1539.07 | 212.97 | 1326.10 |
| Second Half of 2019 | 1051.53 | 148.41 | 903.12 |
| First half of 2019 | 1539.07 | 212.97 | 1326.10 |

```auto
`
```

---

<div class="post-metadata">

**Author:** ![noruga12](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@noruga12](https://forum.codewithmosh.com/u/noruga12)\
**Post date:** [November 29, 2024, 2:55am UTC](https://forum.codewithmosh.com/t/in-accurate-data/2170/14 "2024-11-29T02:55:50Z")

</div>

Hey, @raamz909 I have the same problem, as the database values are not synced with Mosh. Were you able to solve the problem?
