# OpenWeatherMap 5 day forecast jumbles into SQL table

**URL:** <https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655>\
**Category:** General\
**Created:** [8 July 2023 20:37 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655 "2023-07-08T20:37:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbmgf7](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rbmgf7](https://discourse.nodered.org/u/rbmgf7)\
**Post date:** [8 July 2023 20:37 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/1 "2023-07-08T20:37:55Z")

</div>

I have the OpenWeatherMap 5 day forecast payload going into a Split to separate into 40 individual payloads and according to the debug, they Split in chronological order. However, I have it all going directly to a SQLite table and when I open the database, few of the date/times are mixed up (the last payload is shown from the debug as 7-13 but the table has a 7-9 date/time). I figure I can do an Order By command but unsure how the payloads get jumbled in between.

 ![Screenshot 2023-07-08 153442](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e73313d788d50610bc2c10a3962578e009cb341.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 July 2023 20:53 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/2 "2023-07-08T20:53:15Z")

</div>

Do you mean the data are correct in the db, it is just that without an order by it is not coming back from the query in the order you expect? If so then that is not unusual. You cannot rely on the order returned by a query if you do not order it explicitly.

---

<div class="post-metadata">

**Author:** ![rbmgf7](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@rbmgf7](https://discourse.nodered.org/u/rbmgf7)\
**Post date:** [8 July 2023 22:20 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/3 "2023-07-08T22:20:54Z")

</div>

The data is in order from the debug going into the SQL node but when I check the table in SQLiteStudio, about 95% is in order with a few outliers that seemed to have gotten out of order.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 July 2023 01:21 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/4 "2023-07-09T01:21:05Z")

</div>

As with any SQL table, you need to create an index. That should then ensure that any queries come back in the right order.

[CREATE INDEX (sqlite.org)](https://www.sqlite.org/lang_createindex.html)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [9 July 2023 08:06 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/5 "2023-07-09T08:06:21Z")

</div>

Don't worry about sorting the data when you insert it, just sort it in the query.

[How to Order by Date in SQLite | LearnSQL.com](https://learnsql.com/cookbook/how-to-order-by-date-in-sqlite/#:~:text=Use%20the%20ORDER%20BY%20keyword,shown%20last%2C%20etc.)).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 September 2023 08:06 UTC](https://discourse.nodered.org/t/openweathermap-5-day-forecast-jumbles-into-sql-table/79655/6 "2023-09-07T08:06:30Z")

</div>

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