none
How to Join 2 tables if datetime diff is within range?

    Question

  • Hi, problem figuring out how to join tables if the datediff ? is within range.  

    There are 3 tables  a main table then 2 sub tables, these are measurements with a date/time value.  Im trying to take the datetime entries from the 2 sub tables and match them, then add  them to the main table

    subtable1 has SampleID, datetime, 

    subtable2 has TesterID, datetime

    maintable has SampleID, datetime, TesterID, datetime

    so the maintable would always have the sampleID value and datetime regardless.  but it would only JOIN the testerID and its datetime, only IF these 2 datetime values were close, and the datediff interval was set to 1 second.

     its a function call that fills the main tables matching columns but only if the testerIDs datetime is close to the sampleIDs time????

    thanks


    Saturday, January 25, 2014 5:26 PM

Answers

  • SELECT ...
    FROM   maintable m
    LEFT   JOIN subtable s ON m.sampleID = s.SampleID
                          AND s.datecol BETWEEN dateadd(ss, -1, m.sampletime) AND dateadd(ss, 1, m.sampletime)

    I'm avoiding datediff, in order to able to use any index on datecol.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Marked as answer by SDBrad5678 Saturday, January 25, 2014 6:31 PM
    Saturday, January 25, 2014 5:42 PM
  • fixed it, the logic was wrong,

     SELECT * FROM main5 m LEFT 
    
    JOIN Ptes s ON m.incDatetime =    m.incDatetime
                    AND s.pandatetime BETWEEN dateadd(ss, -1, 
    
    m.incdatetime) AND dateadd(ss, 2, m.incDatetime); 
    good thing that sql and computers in general tend to work better in the morning.

    • Marked as answer by SDBrad5678 Wednesday, January 29, 2014 7:52 PM
    Monday, January 27, 2014 6:29 PM

All replies

  • SELECT ...
    FROM   maintable m
    LEFT   JOIN subtable s ON m.sampleID = s.SampleID
                          AND s.datecol BETWEEN dateadd(ss, -1, m.sampletime) AND dateadd(ss, 1, m.sampletime)

    I'm avoiding datediff, in order to able to use any index on datecol.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    • Marked as answer by SDBrad5678 Saturday, January 25, 2014 6:31 PM
    Saturday, January 25, 2014 5:42 PM
  • WOW! i had not tried the reference, like m for maintable m

    will work on this and reply thanks SO much

    Saturday, January 25, 2014 6:03 PM
  • SELECT *
    FROM   maintable m
    LEFT   JOIN subtable1 s ON m.sampleID = s.SampleID
                          AND s.datetime BETWEEN dateadd(ss, -1, m.datetime) AND dateadd(ss, 1, m.datetime)

    and populated the tables with ids and datetime values and the query links only those within a second, or any value put in that last part thats '1' now

    several parts i was missing but it works fine thanks again!

    Saturday, January 25, 2014 6:36 PM
  • Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 

    This is minimal polite behavior on SQL forums. Thanks for making us do your typing and DDL for you :( 

    >> There are 3 tables; a main table then 2 sub tables, <<

    Really? Main table? Sub-tables? There are no such terms in SQL. Trust me on that; I helped with the Standards :) We have referenced referencing tables in the DRI model of SQL. 

    >> these are measurements with a date/time value. <<

    Do you really need the full timestamp down to nanoseconds and not just a DATE? Oh, we also have no sample data :( So we have to guess at precision, constraints, keys, etc. 

    See why we need DDL? Is this relationship 1:1, 1:M OR N:1? My guess is that a tester can do many samples, but a sample has only one tester. And what were those two timestamps? Not redundant copies from the referenced tables!! That would non-normalized. 

    >> so the Sample_Tester_Relationship would always have the sample_nbr value and <something>_timestamp regardless. But it would only JOIN the tester_id and its DATETIME, only IF these 2 DATETIME values were close, and the DATEDIFF interval was set to 1 second. <<

    No, you do not do a JOIN inside a base table. That is VIEW.

    >> It is a function [sic: procedure, Functions return scalar values] call that fills the main tables matching columns but only if the tester_id DATETIME is close to the sample_id time? <<

    No sample data, no sample code and no business rules about ties. Here is my final guess at normalizing this problem: 

    CREATE TABLE Samples
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY,
     ..);

    CREATE TABLE Testers
    (tester_id CHAR(10) NOT NULL PRIMARY KEY,
     ..);

    CREATE TABLE Sample_Tester_Relationship --- needs a real name!
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY
     REFERENCES Samples
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     tester_id CHAR(10) NOT NULL
     REFERENCES Testers
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     PRIMARY KEY (sample_nbr, tester_id),
     tester_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     sample_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     CHECK (ABS (DATEDIFF (SECOND, tester_timestamp, sample_timestamp) <= 1) );

    Most of the work in SQL is in DDL, not DML. 


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Saturday, January 25, 2014 8:52 PM
  • Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 

    This is minimal polite behavior on SQL forums. Thanks for making us do your typing and DDL for you :( 

    >> There are 3 tables; a main table then 2 sub tables, <<

    Really? Main table? Sub-tables? There are no such terms in SQL. Trust me on that; I helped with the Standards :) We have referenced referencing tables in the DRI model of SQL. 

    >> these are measurements with a date/time value. << 

    ++Both of them, the measurementID and otherID  have a millisecond timestamp, the goal is to associate these 2 measurements, they are coming from different systems.  

    Do you really need the full timestamp down to nanoseconds and not just a DATE? Oh, we also have no sample data :( So we have to guess at precision, constraints, keys, etc. 

    See why we need DDL? Is this relationship 1:1, 1:M OR N:1? My guess is that a tester can do many samples, but a sample has only one tester. And what were those two timestamps? Not redundant copies from the referenced tables!! That would non-normalized. 


    >> so the Sample_Tester_Relationship would always have the sample_nbr value and <something>_timestamp regardless. But it would only JOIN the tester_id and its DATETIME, only IF these 2 DATETIME values were close, and the DATEDIFF interval was set to 1 second. <<

    No, you do not do a JOIN inside a base table. That is VIEW.

    >> It is a function [sic: procedure, Functions return scalar values] call that fills the main tables matching columns but only if the tester_id DATETIME is close to the sample_id time? <<

    No sample data, no sample code and no business rules about ties. Here is my final guess at normalizing this problem: 

    CREATE TABLE Samples
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY,
     ..);

    CREATE TABLE Testers
    (tester_id CHAR(10) NOT NULL PRIMARY KEY,
     ..);

    CREATE TABLE Sample_Tester_Relationship --- needs a real name!
    (sample_nbr CHAR(12) NOT NULL PRIMARY KEY
     REFERENCES Samples
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     tester_id CHAR(10) NOT NULL
     REFERENCES Testers
      ON UPDATE CASCADE
      ON DELETE CASCADE,
     PRIMARY KEY (sample_nbr, tester_id),
     tester_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     sample_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
     CHECK (ABS (DATEDIFF (SECOND, tester_timestamp, sample_timestamp) <= 1) );

    Most of the work in SQL is in DDL, not DML. 

    I will try this out and advise.


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Dear Celko

    thank you for this constructive feedback, clearly you're an expert and I am going to be better for following this advice.  In the 1970s I was told to avoid going into software because Japan had invented a way for computers to write their own code, so programmers would be out of a job and the field would be a dead-end.  I didnt formally begin training in sw until the 90s.  SQL is one of those last frontiers i never trained in.  but now Im trying to learn and find anything i can read to absorb it.

    I posted in laymans words because i thought thats how you experts would prefer it described, clearly not.  I will now take the time to read each reference to the standards...

      

    Saturday, January 25, 2014 9:40 PM
  • Mr Celko, wow, i had no idea you were so famous!  and you talked to me... Im honored.   i want to know everything there is about SQL.    i fall asleep listening to sql videos on youtube, and wake up watching more.  immersion works for me.  i have to hurry before it wears off.  what can i do, where is your website, how can i learn from you?
    Sunday, January 26, 2014 12:27 AM
  • >>  In the 1970s I was told to avoid going into software because Japan had invented a way for computers to write their own code, so programmers would be out of a job and the field would be a dead-end. <<

    LOL! That was not Japan; that was the DoD boys in the 1970's. I was at AIRMICS and we had contracts with Mack Alford and the guys at Huntsville for “specification languages” that could turn specs into programs. Good times! I used to write software engineering columns back then. It was a failure, but we did get some validation techniques for software that cannot fail (think: atom bombs). 

    >> I posted in layman's words because I thought that is how you experts would prefer it described, clearly not.  I will now take the time to read each reference to the standards. <<

    No, try to talk shop. RDBMS is a very different from OO and procedural languages. A good place to start would be naive E-R modeling. It has a simple diagram and it makes you ask basic questions. For example, in your example are those dates attributes of a tester? Of a sample? Nope; nobody has a clock in their chest. They mark an event, the testing. Think of a book and an author. He does not have a book when he born; there is an authorship relationship, which can be 1:M or N:M. 


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Sunday, January 26, 2014 2:04 AM
  • well thats irony for you, i was told that because Japan was in such competition for the US in supercomputers, they beat us because even if the CDC or Cray, or to a lesser extent anything ibm made was powerful, Japan won because no more punched cards or any of that, they had machines that programmed... something.  Thats how it was conveyed from some news of the day;  DoD stuff? one can only imagine the applications and complexity.  well unless you were there.  The work that went in to machines then...  Not familiar with the Huntsville group but its staggering how much systems cost and processing power and hand made complexity, and support teams vs. today;  

    I remember probably around 80? 81? driving thru downtown los angeles to find the store called Computerland.  they had one PC-XT in a nice display window.  i couldnt find parking and gave up trying to see it.  that was the only store that had this on hand.  I sure miscalculated that market... 

    Well anyhow, its amazing you ask me to add complexity because usually Im so verbose (in other kinds of work) spelling out all the details, people dont answer or say why to you add so much extra junk? just get to the point.    in this case, 2 different computers from a long distance apart will put some measurement data together, and it has to be 1 second or less, apart.  simple and reliable then store the data into sql.  ok maybe sql has some method to do this sorting already?     in the followup i posted the working code but failed to show the tables and values.  looking at examples in some sql books they seem to always list the problem description, then a table, insert into + data, and then the select from part...    i could try to do that

    Sunday, January 26, 2014 3:17 AM
  • Hi,

    well i still have not got this to work in the code.  i made the logic work but the code?

    there is some date time problem.  some invisible part of the values not agreeing.  the 2 datetimes below, they "seem" close.  test for: less than 2 seconds apart??  none.  99999 seconds? none.  11 years?  none.  there are 2 different programs entering the values, i wonder if the sql is formatting the display part but reading something foreign and it compares the wrong thing;  in one of the fields it was coming in as 2014-01-26T19:26:33.54.322  but i tried to convert before sending it into the table...   dont know, it should work.  this is whats displayed in the microsoft sql management studio doing a

    select * from main5, ptes5

    2014-01-26 19:25:07.000	11	 179518	2014-01-26 19:28:04.000
    2014-01-26 19:25:07.000	12	 179517	2014-01-26 19:28:02.000
    2014-01-26 19:25:07.000	13	 179516	2014-01-26 19:28:00.000
    2014-01-26 19:25:07.000	14	 179515	2014-01-26 19:27:58.000
    2014-01-26 19:25:07.000	15	 179514	2014-01-26 19:27:45.000
    2014-01-26 19:25:07.000	16	 179513	2014-01-26 19:27:45.000
    2014-01-26 19:25:07.000	17	179512	2014-01-26 19:27:27.000
    2014-01-26 19:25:07.000	18	179511	2014-01-26 19:27:26.000
    2014-01-26 19:25:07.000	19	179510	2014-01-26 19:27:24.000
    2014-01-26 19:25:20.000	1	175091	2014-01-26 13:57:24.000
    2014-01-26 19:25:20.000	2	175090	2014-01-26 13:57:03.000
    2014-01-26 19:25:20.000	3	175089	2014-01-26 13:57:02.000
    2014-01-26 19:25:20.000	4	175088	2014-01-26 13:57:01.000 
    2014-01-26 19:25:20.000	10	 179519	2014-01-26 19:28:05.000
    2014-01-26 19:25:20.000	11	 179518	2014-01-26 19:28:04.000
    2014-01-26 19:25:20.000	12	 179517	2014-01-26 19:28:02.000
    2014-01-26 19:25:20.000	13	 179516	2014-01-26 19:28:00.000
    2014-01-26 19:25:20.000	14	 179515	2014-01-26 19:27:58.000
    2014-01-26 19:25:20.000	15	 179514	2014-01-26 19:27:45.000
    2014-01-26 19:25:20.000	16	 179513	2014-01-26 19:27:45.000
    2014-01-26 19:25:20.000	17	179512	2014-01-26 19:27:27.000
    2014-01-26 19:25:20.000	18	179511	2014-01-26 19:27:26.000


    • Edited by SDBrad5678 Monday, January 27, 2014 4:17 AM
    Monday, January 27, 2014 4:14 AM
  • So what is the query  you are using?


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Monday, January 27, 2014 8:31 AM
  • SqlDataSource1.InsertCommand = @"SELECT * FROM main5 m LEFT 
    
    JOIN Ptes s ON m.incDatetime = s.pandatetime " +
                    "AND s.pandatetime BETWEEN dateadd(ss, -1, 
    
    m.incdatetime) AND dateadd(ss, 10, m.incdatetime); ";
    
                SqlDataSource1.Insert();
    insert into [ptes] (panid, pandatetime) values 
    
    
    (' 179497',	'1/26/2014 7:26:11 PM'),
    (' 179519',	'1/26/2014 7:28:05 PM'),
    (' 179518',	'1/26/2014 7:28:04 PM'),
    (' 179517',	'1/26/2014 7:28:02 PM'),
    (' 179516',	'1/26/2014 7:28:00 PM'),
    (' 179515',	'1/26/2014 7:27:58 PM'),
    (' 179514',	'1/26/2014 7:27:45 PM'),
    (' 179513',	'1/26/2014 7:27:45 PM'),
     ('179512',	'1/26/2014 7:27:27 PM'),
     ('179511',	'1/26/2014 7:27:26 PM'),
     ('179510',	'1/26/2014 7:27:24 PM');


    insert into Main5 (incIG, incDatetime) values 
     	 	 	 
     ('IG5c45215deecf',	'1/26/2014 7:18:43 PM'),	 	 
     ('IGcb0b6a4707b7',	'1/26/2014 7:19:37 PM'),	 	 
     ('IG564982d5df28',	'1/26/2014 7:20:50 PM'), 	 
     ('IGcc73dc2f520',	'1/26/2014 7:21:01 PM'),	 	 
     ('IGe5cd0dbef442',	'1/26/2014 7:23:30 PM'),	 	 
     ('IG5c96be774333',	'1/26/2014 7:23:59 PM'),	 	 
     ('IG3292bd6e6aca',	'1/26/2014 7:25:07 PM'),	 	 
     ('IG00d9278b94a6',	'1/26/2014 7:25:20 PM');	
    

    first is the c# code with  the query string, the next 2 are the insert into, tables, almost forgot:

    CREATE TABLE [dbo].[main5]
    (
        [Id] INT NOT NULL identity PRIMARY KEY, 
        [incIG] VARCHAR(MAX) NULL, 
        [incDatetime] DATETIME NULL, 
        [panid] VARCHAR(MAX) NULL, 
        [pandatetime] DATETIME NULL
    )
    
    CREATE TABLE [dbo].[ptes]
    (
    	[Id] INT NOT NULL identity PRIMARY KEY, 
            [panid] VARCHAR(MAX) NULL, 
            [pandatetime] DATETIME NULL
    )
    

    problem:  main5 is the reference.  only bring in the ptes values if the datetime stamp matches within 2 seconds.  the resulting gridview should show the values in panid and pandatetime if they match.    After more thought, main5 should have another column for "Matched=true" so that i can sort for that instead of looking for non-nulls in the pandatetime?  but first things first.  the values entered do not match within 99 years according to my logic

    Monday, January 27, 2014 5:32 PM
  • fixed it, the logic was wrong,

     SELECT * FROM main5 m LEFT 
    
    JOIN Ptes s ON m.incDatetime =    m.incDatetime
                    AND s.pandatetime BETWEEN dateadd(ss, -1, 
    
    m.incdatetime) AND dateadd(ss, 2, m.incDatetime); 
    good thing that sql and computers in general tend to work better in the morning.

    • Marked as answer by SDBrad5678 Wednesday, January 29, 2014 7:52 PM
    Monday, January 27, 2014 6:29 PM
  • still doesnt work... the grid view is not updating, even with the range of 55555 seconds difference nothing shows up in the grid
    Monday, January 27, 2014 6:42 PM
  • ok now i found out why....   using sqldatasource1 for table 1 main5 and sqldatasource2 for table 2 ptes
    Monday, January 27, 2014 7:16 PM
  • ok this cannot possibly work at all.   the sql command is being sent into a table? but it has no way to reference a 2nd table...

    im completely at a loss of ideas.  the sql management studio can work because it sees both tables.  cannot figure out how to see more than one table...

    Monday, January 27, 2014 8:53 PM
  • I'm sorry I've been elsewhere (and I will be elsewhere for the next couple of hours as well), but you had an InsertCommand that was a SELECT statement?

    It appears that there is a mix of confusion with the C# code and the SQL code. Let's focus on getting the SQL code right first.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Monday, January 27, 2014 11:17 PM
  • the sql code part works great when its in the sql managment console.  i perfected it there then sent it on to the c# project

    i think the problem is that im sending one table a reference to an outside table and it crashes.

    i had tried putting this query into the connection string builder when refreshing the gridview source since at that level it can see both tables.  

    Monday, January 27, 2014 11:58 PM
  • In that case we need to see the C# code. Although this is not really the forum for that type of question.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Tuesday, January 28, 2014 8:28 AM
  •  SqlDataSource1.InsertCommand = @" SELECT * FROM main5 m LEFT 
    
    JOIN " +SqlDataSource2 + " s ON m.incDatetime =    m.incDatetime" +
                  "  AND s.pandatetime BETWEEN dateadd(ss, -1, "+
    
    "m.incdatetime) AND dateadd(ss," + TextBox3.Text + ", m.incDatetime); ";

    i picked c# but its not formatting in there.   the ptes table is accessed by SqlDateSource2.

    Seems like this needs to be done from a higher level up, something that can see both tables, how is that done?   the main table is always there, the ptes entry is only added if the datetime matches any entry in the main5 within a time window of about 2 seconds, i added the textbox to set the value but it can be hardwired to 2.

    how can SQL operate on 2 different tables where this would work, from within c# code?

    Tuesday, January 28, 2014 3:48 PM
  • An InsertCommand is for writing data back to SQL Server from your SqlDataAdapter, so this does not look right. If SqlDataSource2 is also a SqlDataAdapter, I can't make much sense out of this at all.

    I have no idea what you are trying to achieve, but maybe:

    SqlCommand cmd = new SqlCommand(cn);
    cmd.CommandText =
       @"SELECT *
         FROM main5 m
         LEFT JOIN Ptes s ON m.incDatetime = s.pandatetime
                        AND s.pandatetime BETWEEN dateadd(ss, -1, m.incdatetime) AND
                                          dateadd(ss, @marin, m.incdatetime);";
    cmd.Parameters.Add("@margin", SqlDbType.Int).Value = TextBox3.Text;
    da new = new SqlDataAdapter(cmd);
    da.Fill();


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Tuesday, January 28, 2014 10:45 PM
  • on im working on it...  
    Tuesday, January 28, 2014 10:56 PM
  • no idea what im trying to do.  ok:

    there are 2 different data sources from 2 different web services.   there is  a text word, and time stamp for each one.  they must be read at different times.  i only care about when both time stamp values are ALMOST the same, close within 2 or 3 seconds.  

    so in the computer?  we have 2 different text/time pairs.  if the time is the same or close then its good, otherwise its reject.

    if i put these into one table?  the date looks like this:

    1  ig123   1/1/27/2014 4:25:01 PM   null    null
    2  igffc6  1/1/27/2014 4:25:32 PM   null    null
    3  ig6545  1/1/27/2014 4:25:34 PM   null    null
    4  igff456 1/1/27/2014 4:26:11 PM   null    null
    5  null    null      2f456 1/1/27/2014 4:26:11 PM
    6  null    null      4f456 1/1/27/2014 4:26:12 PM
    7  null    null      df456 1/1/27/2014 4:26:22 PM
    8  null    null      1f456 1/1/27/2014 4:26:23 PM
    9

    so i thought oh, just use 2 tables, then use the compare or datediff to match up values.  but this is not working, no code i can find or work with does such a compare operation on 2 different separate tables when its in the C# code, working on more than 1 table which is an SqlDataSource1 or 2?  doesnt seem to be common practice. 

    in the above data list, if it must be in one table, the logic would be this:  there are left values and right values.  if the datetime matches? within X seconds? 2? then join them for further processing.   they can be added farther down in the table, i dont care just LINE UP OR JOIN THE 2 SETS OF DATA BASED ON THE DATETIME VALUE OF BOTH

    read one leftvalue.  for every rightvalue that is not null, compare if its datetime diff <2, if true? insert the rightvalue at the ID being used.

    read next leftvalue to end...

    now in the sql management studio, where it can see both tables? the logic already works. i posted the working logic.  i though it was done.  in asp.net with c# there  it does not work, to see the table, to work with a table, its SqlDataSource1 you get one table.    so now, new logic has to be created to sift thru this differently.  if there was some way to be able to send an SQL statement into "something" that could see the 2 tables? the problem would be solved

    Wednesday, January 29, 2014 4:25 AM
  • So in fact, you don't have data in a couple of tables in a single database, but instead the data comes from two different web services? Pushing the data down to SQL Server only to find dates that are close in time does not seem efficient to me.

    I think you should move over to a .Net forum, because the correct solution for your problem may not relate SQL Server very much at all.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
    Wednesday, January 29, 2014 11:34 AM
  • no, the data is in 2 tables, it gets updated and fills 2 tables in one database.  I explained the source of the data in case it would be relevant, the data coming in is independent.

    so if the asp.net was able to operate on 2 tables, which it doesnt appear to be able to, it would be done;  now what i said was that ok i use one table instead of 2 but the table gets filled in parts.  is there a command to sort this table and fill in values based on the timedate comparison.  using sql.


    • Edited by SDBrad5678 Wednesday, January 29, 2014 3:40 PM
    Wednesday, January 29, 2014 3:39 PM
  • ok will consider the question to be finished.  its not correct to say there are no tables and no data;  but  i will try some different kind of solution to solve the problem and not pursue this question anymore.
    Wednesday, January 29, 2014 7:55 PM