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 |
|
Linok
Starting Member
34 Posts |
Posted - 2008-03-20 : 11:23:35
|
| Hey everyone,I've found lot of other people experiencing the same problem I'm having, but I can't get any of their solutions to work for me. I have two tables with the exact same structure Today and Yesterday. I'm trying to compare a price column from Yesterday's column against Today's and I'm getting the 'The multi-part identifier '' could not be bound' error. Here's the code I'm using:DECLARE @ProgramName varchar(100)SET @ProgramName = 'AffiliateName'SELECT CJ_RawImport_Today.* FROM CJ_RawImport_Today WHERE (CJ_RawImport_Today.ProgramName = @ProgramName) AND (CJ_RawImport_Today.RetailPrice < CJ_RawImport_Yesterday.Price)Anyone have a suggestion?Thanks in advance!--Joel |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-20 : 11:25:58
|
| Can you provide the DDL of table with some sample data? |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-03-20 : 11:28:14
|
| so you've got 2 tables? your query is only referencing 1 though?Em |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-03-20 : 11:31:16
|
presumably something like this...SELECT CJ_RawImport_Today.* FROM CJ_RawImport_Today join CJ_RawImport_Yesterday on CJ_RawImport_Today.someID_column = CJ_RawImport_Yesterday.someID_columnWHERE CJ_RawImport_Today.ProgramName = @ProgramName AND CJ_RawImport_Today.RetailPrice < CJ_RawImport_Yesterday.Price Em |
 |
|
|
Linok
Starting Member
34 Posts |
Posted - 2008-03-20 : 11:41:06
|
| Yes, I have 2 tables, however both the exact same schema. This part of the database is meant to be a raw storage repository for the affiliate data. Everyday, there is a scheduled task that'll move Today's data to Yesterday's table and repopulate Today's table with the days new data. I need a way to compare the price column to Today's data against Yesterday's to determine is there has been a price reduction (aka an item has gone on sale). If it would help, here's the schema for for tables:GO/****** Object: Table [dbo].[CJ_RawImport_Today] Script Date: 03/20/2008 11:40:33 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[CJ_RawImport_Today]( [Id] [int] IDENTITY(1,1) NOT NULL, [ProgramName] [varchar](75) NULL, [ProgramUrl] [varchar](100) NULL, [CatalogName] [varchar](50) NULL, [LastUpdated] [smalldatetime] NULL, [Name] [varchar](75) NULL, [Keywords] [varchar](100) NULL, [Description] [varchar](300) NULL, [SKU] [varchar](50) NULL, [Manufacturer] [varchar](50) NULL, [ManufacturerId] [varchar](50) NULL, [UPC] [varchar](50) NULL, [ISBN] [varchar](15) NULL, [Currency] [varchar](5) NULL, [SalePrice] [money] NULL, [Price] [money] NULL, [RetailPrice] [money] NULL, [FromPrice] [money] NULL, [BuyUrl] [nvarchar](500) NULL, [ImpressionUrl] [varchar](500) NULL, [ImageUrl] [varchar](500) NULL, [AdvertiserCategory] [varchar](50) NULL, [ThirdPartyId] [varchar](50) NULL, [ThirdPartyCategory] [varchar](50) NULL, [Author] [varchar](50) NULL, [Artist] [varchar](50) NULL, [Title] [varchar](50) NULL, [Publisher] [varchar](50) NULL, [Label] [varchar](50) NULL, [Format] [varchar](50) NULL, [Special] [varchar](50) NULL, [Gift] [varchar](50) NULL, [PromotionalText] [varchar](200) NULL, [StartDate] [smalldatetime] NULL, [EndDate] [smalldatetime] NULL, [Offline] [varchar](50) NULL, [OnlineInStock] [varchar](5) NULL, [Condition] [varchar](50) NULL, [Warranty] [varchar](50) NULL, [StandardShippingCost] [varchar](50) NULL, [IsSale] [bit] NULL CONSTRAINT [DF_CJ_RawImport_Today_IsSale] DEFAULT ((0)), [DisplaySalePrice] [money] NULL, [DisplayRetailPrice] [money] NULL, [IsNewItem] [bit] NULL CONSTRAINT [DF_CJ_RawImport_Today_IsNewItem] DEFAULT ((0)), CONSTRAINT [PK_CJ_RawImport] PRIMARY KEY CLUSTERED ( [Id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFF |
 |
|
|
|
|
|
|
|