sql - Is it possible to return part of a field from the last row entered into a table -


I am proposing a table (so far the design has not been settled and depending on the ideas expressed in it Answer this question) which will have the primary key of type int (auto-irrigating) and a field (return period type type), which will include data as '06 2013 '(this example represented in June 2013).

I would just like to go back 06 or that is in the final record recorded in the table. This table will not increase by more than 4 records per year (hence it will never grow bigger) It also has a column that shows the date of the last entry.

This column is considered as the most suitable candidate for getting my brain at least the previous record, so I want to know if there is an inbuilt function to compare the date of SQL, then the query Runs in the closest match in the column, and to return the first two letters of a field.

So far I have:

  choose Return from Return (Return Period, 1,2) where date @ return = & lt; And this is where I got stuck & gt;   

What I am searching for is a section that will get the last entered record using the date that the query is run as its reference point (Date is a record on DateRetunEntered type date

Of course it can be an easy way to ensure that someone has a final record, in which case I'm open to suggestions. / P>

thanks < / P>

I think you have a return period for example in the form of a datetime As a varchar 01.06.2013 as a DATETIME (the first day of 06.2013) as 06 2013 .

In this case, if I If your question has been received, you can use it to get the current time:

  Select Return Date 1 month (Return Period), where Date Date and Dated Date = 0 } = As per the date (), the order return can be repeated DESC   

if you enter return period as a varchar

  Select Top 1 Left (ReturnPeriod, 2) from reverse whereReturnEntered & lieutenant; Date return by date = GETDATE () DESC    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -