distinct view

  • its okey now, thank you very much ALL friends :)).[/b]

    this is code for other people, maybe they will need :))

    ALTER VIEW [dbo].[vwPurchase]

    AS

    Select DISTINCT

    max(pur.InPurchaseId) as InPurchaseId,

    ac2.StAccountName as StCompanyName,

    ac1.StAccountName,

    Convert(varchar(20),pur.DtProcDTime,104) as StProcDTime,

    CAST(pur.BoIsActive AS varchar(5)) AS BoIsActive,

    pur.StNotes

    from

    TbPurchase as pur

    INNER JOIN

    TbAccounts as ac1 On ac1.InAccountsId=pur.InOurRelevantId

    INNER JOIN

    TbCompanies as comp ON comp.InCompaniesId=pur.InCompanyId

    INNER JOIN

    TbAccounts as ac2 ON ac2.InAccountsId=comp.InAccountsId

    GROUP BY

    pur.StNotes,

    pur.DtProcDTime,

    ac1.StAccountName,

    ac2.StAccountName,

    pur.BoIsActive

    select * from [vwPurchase]

  • You don't need the distinct in that, because of the group by.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (1/16/2009)


    You don't need the distinct in that, because of the group by.

    For some reason the PO is not understanding...

    You don't need the "DISTINCT" keyword on that query!


    * Noel

Viewing 3 posts - 16 through 17 (of 17 total)

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