I have a Query: SELECT * FROM tble WHERE BILL_DATE BETWEEN '01-NOV-16' AND '01-NOV-16'
Now i need to know if bellow thing can be arranged
For i=1 to 30 Loop SELECT * FROM tble WHERE date BETWEEN 'i-NOV-16' AND 'i-NOV-16'
Insert Data in a table [SQL Server]
asked Dec 19, 2016 at 05:01 AM in Default
Step back and think about the data in a complete set rather than 30 loops.
You have a query that retrieves one day's worth of data, and you want a month's worth, so you are attempting to reuse the 'day' query for the number of days in the month. Don't do it. Write the query to retrieve the data you want, for example
OK. But you might say that you don't always want a complete month. You might want 20 days worth of data starting from some given start date! Again, describe the result set....
And from this you could even make the 'number of days' a parameter.....
But always describe the result set you want SQL to return, rather than describing how to get the results.
answered Dec 19, 2016 at 08:57 AM
Kev Riley ♦♦