Results 1 to 6 of 6

Thread: Query HELP?

  1. #1
    Join Date
    May 2007
    Posts
    5

    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

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Why need trigger? Does the table contain column of prodcut info (id or name)?

  3. #3
    Join Date
    May 2007
    Posts
    5
    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

  4. #4
    Join Date
    May 2007
    Posts
    5
    Yes it has - foreignKey productID

  5. #5
    Join Date
    May 2007
    Posts
    5
    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

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    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
  •