Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ajay
Starting Member
34 Posts |
Posted - 2001-08-24 : 01:10:10
|
| Table structure is like thisfilename varchar(30)category varchar(3)description varchar(2000)Naming convention if field filename is like 'HTMCP then 10digit variable then yymmdd then xyz.htmfor e.g filename entered today would be 'HTMCP1234567890yymmddxyz.htmyymmdd id today's date.category can have value DSD,PUB,MTLDSD will be the date in the form of varchar dd/mm/yyPUB will be the publication nameMTL will be the headline.So for single filename there will be three records.For one file name:HTMCP1234567890yymmddxyz.htm MTL this is the headlineHTMCP1234567890yymmddxyz.htm PUB Newyork timesHTMCP1234567890yymmddxyz.htm DSD dd/mm/yyThe yymmdd in the filename will be equal to the dd/mm/yy in DSD category.Now this table contains millions of records like this;Now i want to retreive latest 50 distinct filename from this table.I have written this query for ORACLE database, because part of my project involves connectivity with oracle database.select distinct filename from table where rownum < 50 order by to_date(substr(filename,16,6),'yymmdd') descorHow is this possible in SQL SERVER 7.0.16,6 bcos the date in the filename starts from 16th position and ends at 21st position.After I run the query it does not gives me the latest records.Thanks in Advanceajay |
|
|
|
|
|