-
Query HELP?
Hi guys i need your help!!
I have a product_sales table:
saleID
salesPrice
saleDate
previouseSalePrice
I need to find the previous sales price of a product?
i assume it must involve a query or trigger
thanks
-
Why need trigger? Does the table contain column of prodcut info (id or name)?
-
Create table [Sales]
(
[SalesID] Integer NOT NULL,
[LocationID] Smallint NOT NULL,
[VendorID] Integer NOT NULL,
[Product] Integer NOT NULL,
[Previous_Sale_Price] Money NULL,
[Sale_Price] Money NULL,
[Commission] Char(3) NOT NULL,
[Date_For_Sales] Datetime NULL,
[Date_Withdrawn_From_Sale] Datetime NULL,
[Sale_Date] Datetime NULL
)
go
Yes it contains foreignkey = productID
-
Yes it has - foreignKey productID
-
Create table [Sales]
(
[SalesID] Integer NOT NULL,
[LocationID] Smallint NOT NULL,
[VendorID] Integer NOT NULL,
[ProductID] Integer NOT NULL,
[Previous_Sale_Price] Money NULL,
[Sale_Price] Money NULL,
[Commission] Char(3) NOT NULL, [Date_For_Sales] Datetime NULL,
[Date_Withdrawn_From_Sale] Datetime NULL,
[Sale_Date] Datetime NULL,
Primary Key ([SalesID])
)
go
-
Then try this:
select ProductID, Previous_Sale_Price from Sales where ...
If you like to get product name, need to join product table.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|