Skip to content
Advertisement

Select data from date range in DB2 SQL

I have a trouble trying get a data in DB2 SQL. I have a table Name StProdMoves and it holds data like this

Now what is the query if I want to select sales data between two dates from a date range?

For example, I want to select the products that stayed in the range 31/12/2018 and 07/01/2019 and brand=SBR and Status=10.

Edit: I trying get the data using this query, but not all products selected show in that range of dates, then show a result like this:

Later as ProducName, Status, Brand, DateIn and DateOut where show all products exist in this date or range of date, like this

Advertisement

Answer

If you have your dates as Numeric values in such a format as you provided, the most efficient way to query your table with DATE parameters should be like below:

We translate the Date input parameters to the Numeric timestamp representation of your data in such a way.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement