2011-12-29 9 views
1

同じクエリに参加する参加する:エラー2は、内部やって、私は内側の2つをやっている

use SalesDWH 
go 


select COUNT([specimen id]) as [count],[practice name],qlmlismapping.[mlis practice id],[practice code],[Requesting Physician] 
from quicklabdump a 
inner join qlmlismapping b 
on (b.[quiklab practice code] = a.[practice code]) 
inner join PracticeandPhysician c 
on (a.[Requesting Physician]=c.doctorfirstname+' '+c.DOCTORLASTNAME) 
where [DATE entered] between '12/1/2011' and '12/31/2011' 
group by quicklabdump.[practice name],qlmlismapping.[mlis practice id],[practice code],[Requesting Physician] 
order by [count] desc 

と、このエラーになっ:

Msg 4104, Level 16, State 1, Line 10 
The multi-part identifier "quicklabdump.practice name" could not be bound. 
Msg 4104, Level 16, State 1, Line 10 
The multi-part identifier "qlmlismapping.mlis practice id" could not be bound. 
Msg 4104, Level 16, State 1, Line 3 
The multi-part identifier "qlmlismapping.mlis practice id" could not be bound. 

私が間違っているのは何を?ジョインは間違っていますか?

答えて

4

  • は、すべての列に
  • 使用意味のあるエイリアス(QLD、QLM、PAPなど)
  • 使用ISO日付を修飾しても、あなたの

    select 
         COUNT([specimen id]) as [count], 
         [practice name], 
         b.[mlis practice id], 
         [practice code], 
         [Requesting Physician] 
    from 
        quicklabdump a 
        inner join 
        qlmlismapping b on (b.[quiklab practice code] = a.[practice code]) 
        inner join 
        PracticeandPhysician c on (a.[Requesting Physician]=c.doctorfirstname+' '+c.DOCTORLASTNAME) 
    where 
        [DATE entered] between '12/1/2011' and '12/31/2011' 
    group by 
        a.[practice name], 
        b.[mlis practice id], 
        [practice code], 
        [Requesting Physician] 
    order by 
        [count] desc 
    

    を登録しよういくつかの注意と同じエイリアスを使用しますyyyymmdd

  • 空白なしで列名を使用してください。
4

公開されている相関名ではない別名で非表示にしているため、残りのクエリでqlmlismappingなどを参照することはできません。

エイリアスが実際に定義されている場所を除くすべての場所で、ベーステーブル名の代わりにエイリアス名を使用する必要があります。

関連する問題