Matching recoreds

  • Will this query pull out records where the card has been used more than once with the date range, one or more different orders?

  • That's the intention.

    If you're likely to have a run of questions on this topic, why not post some table structures and sample data for people to test against?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • I will just that to share the knowledge

  • Here is the table structure:

    CREATE TABLE [dbo].[T_Payments](

    [OrderID] [int] NOT NULL,

    [CCNumber] [nvarchar](1024) NULL,

    GO

    CREATE TABLE [dbo].[OrderHeader](

    [OrderID] [int] NOT NULL,

    [CustomerID] [int] NULL,

    [ShipSurname] [nvarchar](50) NULL,

    [ShipForename] [nvarchar](50) NULL,

    [ShipTitle] [nvarchar](20) NULL,

    [ShipAdd1] [nvarchar](50) NULL,

    [ShipPostcode] [nvarchar](50) NULL,

    [OrderDate] [datetime] NULL,

    [OrderTotal] [money] NULL,

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply