2016-12-08 5 views
-1

이 MS SQL Server SELECT 문에서 오류를 볼 수 있습니까?이 SELECT 문에서 "보낸 사람"이라는 단어 근처의 오류는 어디에 있습니까?

select clientname, our_date_finalized as our_dat, 
    specific_category as specific_c, 
    SUM(total_allowed) as total_allo, 
    SUM(total_charges) as total_char, 
    SUM(savings) as savings, 
    SUM(1) as claims 
Group By 1, 2, 3 
Order By 1, 2, 3 
from lob_activity.dbo.lob_activity where lob = 'Reprc' 

파서는 "근원"키워드 근처에서 오류를 반환하고 있다고 말합니다.

+4

SELECT/FROM/GROUP BY/HAVING WHERE// ORDER BY – pmbAustin

+0

닫기 유권자는이 질문에 특정 문제 코드 또는 문제 설명이 포함되어 있지 않은 점에 대해 설명 할 수 있습니까? – Blorgbeard

+0

주문서의 맨 마지막에 가야합니다 –

답변

5

from의 위치가 잘못되었습니다.

select 
     clientname 
    , our_date_finalized as our_dat 
    , specific_category as specific_c 
    , sum(total_allowed) as total_allo 
    , sum(total_charges) as total_char 
    , sum(savings) as savings 
    , sum(1) as claims 
    from lob_activity.dbo.lob_activity 
    where lob = 'reprc' 
    group by clientname, our_date_finalized, specific_category 
    order by 1, 2, 3 
+0

MS SQL Server를 사용하여 열 번호별로 그룹화 할 수 있습니까? (단지 열 이름을 사용하여 나를 위해 작동하는 것 같다) – sgmoore

+0

@sgmoore 질문에서 쿼리를 사용하고 있습니다,하지만 난 가서 열 이름으로 대답을 업데이 트했습니다. – SqlZim

2

때문에에서 어디 예,이 일 조항은

select clientname, our_date_finalized as our_dat, 
    specific_category as specific_c, 
    SUM(total_allowed) as total_allo, 
    SUM(total_charges) as total_char, 
    SUM(savings) as savings, 
    SUM(1) as claims 
from lob_activity.dbo.lob_activity 
where lob = 'Reprc' 
Group By 1, 2, 3 
Order By 1, 2, 3 
0

함으로써 그룹으로 또는 주문 앞에 와야합니다 :

select clientname, our_date_finalized as our_dat, specific_category as specific_c, SUM(total_allowed) as total_allo, SUM(total_charges) as total_char, SUM(savings) as savings, SUM(1) as claims from lob_activity.dbo.lob_activity where lob = 'Reprc' Group By clientname, equian_date_finalized, specific_category Order By 1, 2, 3