» sql query for displaying start/end points with time interval
sql query for displaying start/end points with time interval
|March 16, 2013
Posted by forumadmin
I have a table called vehicle_Summary and the data loks like:
A_Date vehicle_Name Location_Name
2012-02-08 09:36:20.000 AA000AA Denver
2012-03-08 09:36:20.000 AA000AA Tokyo
2012-04-08 09:30:50.000 AA000AA Melbourne
2012-12-08 09:36:20.000 AA000AA Geneva
2012-22-08 00:00:00.000 AA000AA NY
2012-01-08 09:36:20.000 DPT011 Hobart
2012-03-08 09:36:20.000 DPT011 Tasmania
2012-04-08 09:30:50.000 DPT011 Java
2012-12-08 09:36:20.000 DPT011 Manila
2012-22-08 00:00:00.000 DPT011 Singapore
and i have vehicle_Info table as
So first i search all vehicles from vehicle_Info table and
when i query b/w two time interval on vehicle_Summary
say 2012-02-08 04:44:44.444 and 2012-12-08 09:44:44.444
wt i expect is
vehicleName start_Point end_Point
AA000AA Denver Geneva
DPT011 Tasmania Manila
im using MS Sql server 2k5 , i want this as query instead of performing the manual logic in C#. is this possible
More Related Questions
- How can I do an UPDATE statement with JOIN in SQL? I need to update this table in MS SQL Server 2005 with data from its 'parent' table, see below:
- SQL update query using joins I have to update a field with a value which is returned by a join of 3 tables.
,im.sku as iSku
,gm.SKU as GSKU
,mm.ManufacturerId as ManuId
- SQL Server – pull X random records per state I have a table with records for each zip code in the united states. For the purposes of displaying on a map, I need to select X random records per state. How would I go about doing […]
- How do I create unique constraint that also allows nulls in sql server Adding a column to table, and I want a unique constraint, so the column will insert GUID's, but to allow for existing data before column was added, I need to allow for NULL's in the […]
- How to SELECT * INTO [temp table] FROM [stored procedure] How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp table]?
Select all data from BusinessLine into tmpBusLine works fine.
- Delete duplicate records from a SQL table without a primary key I have the below table with the below records in it
create table employee
insert into employee values(1, 'Jack', […]
- TSQL Finding Order that occurred in 3 consecutive months Please help me to generate the following query. Say I have customer table and order table.
- How to append to a text field in t-sql SQL Server 2005 What is the best way to append to a text field using t-sql in Sql Server 2005?
With a varchar I would do this.
update tablename set fieldname = fieldname + 'appended string'
But this […]
- How important is the order of columns in indexes? I've heard that you should put columns that will be the most selective at the beginning of the index declaration. Example:
CREATE NONCLUSTERED INDEX MyINDX on Table1
- Get top 1 row of each group I have a table which I want to get the latest entry for each group. Here's the table:
|ID| DocumentID | Status | DateCreated |
| 2| 1 | S1 | […]