-4

I have a table with 6GB of data and it has past 6 years of records (few millions of rows), but I want to collect data from past 2 weeks.

How to fetch All column data from past 2 weeks in the table. There is any Query helps me to get those data or should I do partition, etc? Any help.

  • 2
    Can you give us an example if the table schema? Does it contain a date field? Do you want whole weeks or a rolling 14 days worth? Please edit your question and provide the query, table definition, any errors you getting and what the problem is. – Sir Swears-a-lot Jul 19 '17 at 19:31
3

It sounds to me like a straight forward select query.

Select field1, field2, etc
from tablename
Where datefield > getdate() -14;

Substitute the fields you want to select and filter, and the tablename.

I would highly reccomend that you take some time to start reading about sql queries. W3 schools would be a good place to start

|improve this answer|||||
  • seems like perfectly valid answer. only suggestion would be to use dateadd instead of implicit date math. ie where datefield > dateadd(day,-14,getdate()) – Bob Klimes Jul 19 '17 at 20:52
  • @BobKlimes cheers. Fair call. I wasnt going to go overboard given the detail provided. – Sir Swears-a-lot Jul 20 '17 at 6:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.