Difference Between 2 Tables

Aug 21, 2006

Hi,

We have 2 tables as follows,

TableA
------------
doc_id ver_id ref_date

TableB
------------
doc_id ver_id ref_min_date

We need to find out the records that exists in TableA but not in TableB
and also to get the minimum of TableA.ref_date from the result.

For example,

TableA has the following rows
doc_id ver_id ref_date
100 1 10-AUG-2006
100 2 12-AUG-2006
100 2 13-AUG-2006
100 2 14-AUG-2006
100 2 15-AUG-2006
200 1 17-AUG-2006
300 1 18-AUG-2006

TableB has the following rows
doc_id ver_id ref_date
100 1 10-AUG-2006
200 1 10-AUG-2006

Result should be as follows
doc_id ver_id ref_date
100 2 12-AUG-2006
300 1 18-AUG-2006

Please help us in writing the query

Thanks
Ashok

View 1 Replies


ADVERTISEMENT

Difference Between Tables

Jan 5, 2007

Hi im trying to find the difference between 2 silmilar tables in sql 2000. 1 table has 279,042 records and the other has 279,003 records, I ideally want to difference so to enable me to merge the two tables
I would really appreciate any help

View 2 Replies View Related

Grabbing The Difference Between Two Tables...

Jun 17, 2008

Hi,
First post here :) Subject might not make sense, so allow me to explain. I have a table, tbl_finalized. A unique record consists of an emp_id, building, and school_year. I have another table, (call it table2) where emp_id, building, and school_year are fields as well. What I'm trying to do is... grab all the emp_id's from table 2 ( along with the school_year and building ) and then see if it exists in tbl_finalized. If it does, I don't want it. I want all the usernames in table2 that don't exist in tbl_finalized.

Here's an example:
table2 contains the following record:
emp_id: xxx, building: 333, school_year: 2008
emp_id: zzz, building: 333, school_year: 2008
emp_id: yyy, building: 444, school_year: 2008

tbl_finalized has the following records:
emp_id: yyy, building: 333, school_year: 2008
emp_id: xxx, building: 333, school_year: 2007
emp_id: xxx, building: 333, school_year: 2008

The result I desire is:
emp_id: zzz, building: 333, school_year: 2008
emp_id: yyy, building: 444, school_year: 2008

I hope this makes sense. If not, please ask and I will do my best to explain. I have light understanding of joins, but not sure how to get the difference like I desire in this case...
TIA.

View 1 Replies View Related

T-SQL (SS2K8) :: Get Difference Between Data In Two Tables

May 27, 2014

I have two similar tables in different database and need to make query to select only the data from the first table that is not available in the second table and there is no unique record for each record , but each row is having different records for example:

CREATE TABLE table1(
[PNR] [nvarchar](10) NOT NULL,
[Tkt_Number] [nvarchar](10) NOT NULL,
[DepaCityName] [nvarchar](50) NULL,
[ArriCityCode] [nvarchar](3) NULL,

[Code] ....

Output should be like this

PNR | TKT_NUMBER | DEPACITYNAME | ARRCITYCODE | NAME
fdf44 12669 Sah DXB lamees

View 8 Replies View Related

Minimum Time Difference Between Tables

Sep 3, 2013

I receive the following result set from TableA (In Time)

7/9/2013 9:27:00.000 AM
7/9/2013 10:24:00.000 AM
7/9/2013 11:25:00.000 AM
7/9/2013 1:23:00.000 PM
7/10/2013 7:27:00.000 AM

Then we receive the following result from TableB (Out Time)

7/9/2013 9:30:00.000 AM
7/9/2013 10:29:00.000 AM
7/9/2013 1:37:00.000 PM
[NULL]
[NULL]

We may not always get Out Times in TableB so I want to merge these into one table to have the In Time and Out Time in separate columns in that one table. In this example with the red type those should be In Time and Out Time for mapped unique identifiers from each table and yet the purple color coded example would have an In Time of 11:25 AM and the Out Time would remain as NULL.

I am using this block of code but is not working the way I want it to because the 11:25am In Time is getting mapped to the 1:37pm Out Time.

and out_time = (select min (out_time)
FROM tableB WHERE
tableB.record# = tableA.record#
and tableB.loc_id = tableA.loc_id

GROUP BY tableB.record#, tableB.loc_id )

It seems I need to focus on the minimum datediff for each record line but can't figure that part out.

View 2 Replies View Related

Difference Between Selecting Into And Temp Tables

Aug 27, 2007

Hello Tsql experts,
Can you please explain to me what the differnce is between selecting into a table and creating a new tabel and inerting in to it like so:

First way:
select names
into #ancestors
from names

and

second way

create table #names(
name varchar(10)
)

insert into #names (name) values(name)
select names from names

is it just personal choice or performance in one method is better than the other.Can you please explain.
Thanks

View 3 Replies View Related

Script / Function ... To Find Difference B/w 2 Similar Tables

Jul 23, 2005

Hi,I m searching for some Script / Function ... to find difference in datab/w 2 similar tables (exactly same fields structure) in sql 2000.plz update me asap !thanks in advance !

View 2 Replies View Related

DB Engine :: Compare Two Tables And Log Difference In New Table With Fields?

Apr 21, 2015

I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column.

View 10 Replies View Related

Can Anyone Give Me A Layman's Explanation Of The Difference Between CURRENT_TIMESTAMP And GETDATE() (if There Is A Difference)?

Oct 24, 2007

Question is in the subject.

Thanks in advance
-Jamie

View 7 Replies View Related

Why Would Tables Pulled In From ODBC In Access Be Different Than Tables In SQL 2005 Tables?

Jan 24, 2008

I'm new to my company, although not new to SQL 2005 and I found something interesting. I don't have an ERD yet, and so I was asking a co-worker what table some data was in, they told me a table that is NOT in SQL Server 2005's list of tables, views or synonyms.

I thought that was strange, and so I searched over and over again and still I couldn't find it. Then I did a select statement the table that Access thinks exists and SQL Server does not show and to my shock, the select statement pulled in data!

So how did this happen? How can I find the object in SSMS folder listing of tables/views or whatever and what am I overlooking?

Thanks,
Keith

View 4 Replies View Related

What Is The Difference Between

Feb 28, 2007

What is the difference between below? And how can I make GETDATE() the same as System.DateTime.Today.ToShortDateString()?
System.DateTime.Today.ToShortDateString()
and
GETDATE()

View 2 Replies View Related

What Is Difference?

Feb 5, 2008

 
Hi all,
What is the difference between SQL Server 2000 & SQL Server 2005?
 
Thanks!

View 2 Replies View Related

Difference

Jul 7, 2000

Can anybody tell me what is the difference between backing up database to a file and backing up to backup device.

Thanx in adv.

View 1 Replies View Related

Difference Between BCP And DTS

Dec 16, 2002

Hello,
I am transfereing Data into text format.
The datas are about 5 table and has almost 50000 to 2 million rows.
I am using the same query for BCP and DTS. But I find the dreference between those. I mean DTS is taking less memory and more time than BCP to complete the process .
Anybody can share any comment for this issue ?.

View 6 Replies View Related

Difference Between SP's

Aug 18, 2004

Can somebody tell or may refer to a site that show the differences between SQL Server 2000 SP2 and SP3a.

Thanks.

View 1 Replies View Related

Is There A Difference?

Mar 10, 2004

Is there really a difference of approach?

I have several things to consider in an estimating database. Production, Shipping, Field Work, Field Hardware, etc...

All of the above have account numbers. Now I was wondering, would there be any benifit to having one table or several tables?

One Table Example

Account (PK) | Category | Description


or

Multiple tables

tbProduction
Account (PK) | Description

tbShipping
Account (PK) | Description

tbProducts
Account (PK) | Description
etc.....


I like having the tables split up and/or all in one.

Any thoughts, pros / cons?

Mike B

View 2 Replies View Related

What's The Difference ???

Apr 9, 2008

What is the difference between stored procedure and functions ?


thanx in advance

View 7 Replies View Related

Difference

May 16, 2006

Hi,
What is the difference between Inline-table value function and multi statement table value function?
Thanks In Advance

View 6 Replies View Related

Difference Between BCP And DTS

Sep 4, 2006

Hi Experts,
please tell me the difference between BCP and DTS

provide me links if possible.


thankyou very much

View 2 Replies View Related

Why The Difference In DTS?

Sep 8, 2006

hello friends,
i've bee working in DTS just from 2 days.

i've one database like 'x' and now i've exported the data to a newly created database 'y'

but in this y database i got much memory like around 30 mb.
why this happend?


sorry if this is a small question.


thankyou friends

View 1 Replies View Related

Difference

Jan 16, 2007

Hi
I want to know the difference between
SQL server Express and
SQL server 2005 Express Edition.

Thanks
Yimoot.

View 1 Replies View Related

Set Difference?

Feb 6, 2007

hi, i'm having difficulty figuring out how to implement a set difference between two queries. the only set operator i've been able to come across is union. thanks in advance!
d

View 3 Replies View Related

Difference Between T-SQL SP And CLR SP

Dec 21, 2007

Hi all,

May any one tell the differnce between t-sql Stored procedure and the same SP written in CLR compatible?.Will CLR SP really improve the performance?

Your response will be highly appreciated.

Thanks in advance

View 1 Replies View Related

Difference Among Them

Jul 6, 2006

Hi everyone,
What is the real difference among them ?
CREATE PROCEDURE sp_devamsizlik
@ADI CHAR(20)
AS
SELECT *
FROM OGRENCI
WHERE ADI=@ADI

GO
--------------------------------------------------------------------------------------

CREATE FUNCTION sp_devamsizlik
(@ADI
CHAR(20) )
RETURN TABLE
BEGIN
RETURN( SELECT * FROM OGRENCI WHERE ADI=@ADI )
END

View 6 Replies View Related

Difference

Apr 24, 2007

Are SQL Server Express & SQL Server 2005 one & the same thing? Or is the former a part of the latter? Actually when I was downloading Visual Web Developer 2005 Express, I was given the option to download Microsoft SQL Server 2005 Express Edition as well; so I am getting confused between SQL Server Express & SQL Server 2005.



I installed SQL Server 2005 in my WinXP Pro m/c. from the Microsoft website (after re-installing WinXP Pro since XP became corrupt). Earlier I used to login to Management Studio Express using my m/c. name followed by a followed by SQLEXPRESS as the server name. So if my m/c. name is MyPC, then I used to login to Management Studio Express using MyPCSQLEXPRESS as the server name but now when I try to login to Management Studio Express using the above server name i.e. MyPCSQLEXPRESS, then an error gets thrown saying



Cannot connect to MyPCSQLEXPRESS.



Now how do I find out what's the server name so that I can login to create & manage databases in Management Studio Express?



Please note that after re-installing WinXP Pro, my m/c. name has remained the same; I didn't change it.



Thanks,



Arpan

View 5 Replies View Related

Difference Between CONTAINS And LIKE

Sep 29, 2007

Hi,
I want to know what are the differencve between CONTAINS and LIKE, Which is better to use and in which condition.????
I searched on google but can't able to find out major differnces or any good article realted to this,

View 5 Replies View Related

Difference

Sep 7, 2007

Hai,
I want to know what is the difference between views and joins. why we are going for views in sql server.

View 8 Replies View Related

Difference Between Variables

Feb 22, 2008

I have two numeric variables in T-SQL - @Var1 and @Var2These variables can be positive or negative. I want to find the difference between the two variables, eg:@Var1 = -50@Var2 = 25Difference = 25 @Var1 = -50@Var2 = -40Difference = 10 @Var1 = 60@Var2 = 10Difference = 50 Is there a function in SQL Server to carry this out? 

View 4 Replies View Related

Month Difference

Mar 11, 2008

How to find a month difference using sql query?               

View 4 Replies View Related

Whats The Difference

Feb 2, 2004

Between having SQL and using SQL server enterprise manager with MSDE

View 1 Replies View Related

Difference Between SP And Function

Nov 29, 2004

Hi All,

It may be sound weird. I want to find the difference between SQL Stored procedure and functions. I knew a couple one is for function, parameter is must where as in SP its not, second is function would return a value whereas procedure wont.

Is there anythign else???

View 6 Replies View Related

Time Difference

Aug 19, 2005

I want to create a View, which contains columns from two tables, and an additional column, which should calculate the difference between two dates.01/05/2005 7:30 AM - 01/05/2005 8:00 AMThe column should be a calculated column,Can I assign the value of a column to a user defined function?In the UDF, how to get the difference between those two dates to be: "00:30"Are there SQL Server functions to time and date that allows me to do so? I have dateadd, datediff, but I am unable to figure out the 2 problems above.thank you,

View 10 Replies View Related

Avg Time Difference

Aug 21, 2005

In my table i have two cols and datatype datetime, for example they has the values,--------StartDate --------------------------------------- StopDate ------______________________________________________01/05/2005 7:30 AM ------------------------ 03/05/2005 10:00 AM13/05/2005 2:30 PM ------------------------- 01/08/2005 8:00 PM_____________________________________________How do I find out the avg time difference between StopDate and StartDate? I tried AVG(StopDate - StartDate ), but it's giving me the following error message. "The average aggregate operation cannot take a smalldatetime data type as an argument."Thanks for any reply.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved