First Record being skipped

  • Hi All, i have this query that works fine, but when it returns records, for each category it returns, it kind of skips the first record and returns the remaining, what could be the cause of this?

    This is the code:

    SELECT TOP (100) PERCENT dbo.tbl_PressAD.FK_AdvertizerId, dbo.tbl_CodeFile.Description AS Advertizer, dbo.tbl_Brand.Description AS Brand,

    dbo.tbl_Publications.Description AS Publication, dbo.tbl_PressAD.IssueDate, dbo.tbl_PressRates.Description AS Position,

    dbo.tbl_PressAD.Amount AS Rate, dbo.tbl_Quality.Description AS Quality, dbo.tbl_BrandAD.Description AS Identifier

    FROM dbo.tbl_Brand INNER JOIN

    dbo.tbl_PressAD ON dbo.tbl_Brand.FK_ProductId = dbo.tbl_PressAD.FK_ProductId AND

    dbo.tbl_Brand.BrandId = dbo.tbl_PressAD.FK_BrandId INNER JOIN

    dbo.tbl_BrandAD ON dbo.tbl_PressAD.FK_BrandADId = dbo.tbl_BrandAD.BrandADId AND

    dbo.tbl_PressAD.FK_BrandId = dbo.tbl_BrandAD.FK_BrandId AND dbo.tbl_PressAD.FK_ProductId = dbo.tbl_BrandAD.FK_ProductId INNER JOIN

    dbo.tbl_PressRates ON dbo.tbl_PressAD.FK_PressRatesId = dbo.tbl_PressRates.RateId AND

    dbo.tbl_PressAD.FK_ColorId = dbo.tbl_PressRates.FK_ColourId AND

    dbo.tbl_PressAD.FK_PublicationId = dbo.tbl_PressRates.FK_PublicationId INNER JOIN

    dbo.tbl_CodeFile ON dbo.tbl_PressAD.FK_AdvertizerId = SUBSTRING(dbo.tbl_CodeFile.CodeFileId, 2, 4) INNER JOIN

    dbo.tbl_Quality ON dbo.tbl_PressAD.FK_QualityId = SUBSTRING(dbo.tbl_Quality.QualityId, 2, 3) INNER JOIN

    dbo.tbl_Publications ON dbo.tbl_PressAD.FK_PublicationId = SUBSTRING(dbo.tbl_Publications.PublicationId, 2, 3)

    WHERE (SUBSTRING(dbo.tbl_CodeFile.CodeFileId, 1, 1) = 'g') AND (dbo.tbl_PressAD.IssueDate BETWEEN @BeginDate AND @EndDate) AND

    (dbo.tbl_PressAD.FK_AdvertizerId = @AdvertizerId)

    ORDER BY identifier

    Please help look into it.

    Thanks

    Timotech

  • If you know of a record that is not being returned, change your INNER JOINs to LEFT JOINs and look for any NULL values when you query for the specific records. Changing the JOINs should bring to light any conditions that cause it to drop out.

    If you're still not getting your data, you will need to post your table structures and some sample data that should come through but doesn't.

    /* Anything is possible but is it worth it? */

Viewing 2 posts - 1 through 1 (of 1 total)

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