magesh manavalan

magesh manavalan

  • NA
  • 331
  • 506.9k

SQL Query to compare two table values?

Jan 11 2012 11:57 PM


SQL Query to compare two table values?

The bellow tables are there:

VPRC_13:

CREATE TABLE [VPRC_13] (
[RptUnitTypeID] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Rpt_Unit] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[YYYYMM] [numeric](4, 0) NOT NULL ,
[Tree_Ind_ID] [Tree_Ind_ID] NOT NULL ,
[proj_adopt] [datetime] NULL ,
[agree_sign] [datetime] NULL ,
[rect_inifund] [datetime] NULL ,
[amt_inifund] [numeric](13, 2) NULL ,
[disp_pip] [datetime] NULL ,
[pip_app_date] [datetime] NULL ,
[per_elect] [numeric](5, 2) NULL ,
[per_women] [numeric](5, 2) NULL ,
[R_Index] [int] NULL ,
[CDATE] [datetime] NULL ,
[MDATE] [datetime] NULL ,
CONSTRAINT [PK_TR_VPRC_13] PRIMARY KEY CLUSTERED
(
[RptUnitTypeID],
[Rpt_Unit],
[YYYYMM],
[Tree_Ind_ID]
) ON [PRIMARY] ,
CONSTRAINT [CK_TR_VPRC_13] CHECK ([per_elect] < 100),
CONSTRAINT [CK_TR_VPRC_13_1] CHECK ([per_women] < 100)
) ON [PRIMARY]
GO



VPRC_60:


CREATE TABLE [VPRC_60] (
[RptUnitTypeID] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Rpt_Unit] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[YYYYMM] [numeric](18, 0) NOT NULL ,
[shg_code] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[name_of_SHG] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[shg_code1] [bigint] NOT NULL ,
[tally_ref_no] [numeric](18, 0) NULL ,
[tally_shg_no] [numeric](18, 0) NULL ,
[dt_for] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
CONSTRAINT [PK_VPRC_60] PRIMARY KEY CLUSTERED
(
[RptUnitTypeID],
[Rpt_Unit],
[YYYYMM],
[name_of_SHG]
) ON [PRIMARY] ,
CONSTRAINT [shguniq] UNIQUE NONCLUSTERED
(
[shg_code]
) ON [PRIMARY] ,
CONSTRAINT [shguniq1] UNIQUE NONCLUSTERED
(
[shg_code1]
) ON [PRIMARY]
) ON [PRIMARY]
GO


I want to select VPRC_13.proj_adopt greater then VPRC_60.dt_for this two dates.

Please reply me soon as possible....

Thanks&Regs

Manavalan




Answers (2)