![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have the following table and I need to select the rows for a specific SiteCode, ProductCode. But I only need the rows with the current price. ie MAX(EffectiveDate) for dates <= NOW() SELECT * FROM Product2PriceGroup WHERE SiteCode = '24' AND ProductCode = '8' AND EffectiveDate = What can I put here to select only rows with the current price? |
|
CREATE TABLE "DBA"."Product2PriceGroup" ( "SiteCode" CHAR(10) NOT NULL, "ProductCode" CHAR(10) NOT NULL, "PriceGroupCode" CHAR(10) NOT NULL, "PriceType" CHAR(1) NOT NULL DEFAULT 'T' CHECK(@COLUMN IN ('T','M','P','L','Q','Y','C')), "EffectiveDate" DATE NOT NULL, "Price" DECIMAL(11,4) NOT NULL, "MinimumCharge" DECIMAL(11,4) NOT NULL, PRIMARY KEY CLUSTERED ("SiteCode", "ProductCode", "PriceGroupCode", "PriceType", "EffectiveDate") ); TIA Eddie Sizemore |
#3
| |||
| |||
|
|
In article <3fdde361$1@forums-1-dub>, esizemorenospam (AT) qx (DOT) net says... I have the following table and I need to select the rows for a specific SiteCode, ProductCode. But I only need the rows with the current price. ie MAX(EffectiveDate) for dates <= NOW() SELECT * FROM Product2PriceGroup WHERE SiteCode = '24' AND ProductCode = '8' AND EffectiveDate = What can I put here to select only rows with the current price? How about: ... AND EffectiveDate = (select max(effectivedate) from Product2PriceGroup where SiteCode= '24' and ProductCode = '8') CREATE TABLE "DBA"."Product2PriceGroup" ( "SiteCode" CHAR(10) NOT NULL, "ProductCode" CHAR(10) NOT NULL, "PriceGroupCode" CHAR(10) NOT NULL, "PriceType" CHAR(1) NOT NULL DEFAULT 'T' CHECK(@COLUMN IN ('T','M','P','L','Q','Y','C')), "EffectiveDate" DATE NOT NULL, "Price" DECIMAL(11,4) NOT NULL, "MinimumCharge" DECIMAL(11,4) NOT NULL, PRIMARY KEY CLUSTERED ("SiteCode", "ProductCode", "PriceGroupCode", "PriceType", "EffectiveDate") ); TIA Eddie Sizemore |
![]() |
| Thread Tools | |
| Display Modes | |
| |