2017-09-27 16 views
0

이 결과를 얻을 수 있었지만 count()의 결과 앞에 분기 이름을 나열하는 방법을 알 수 없습니다.테이블의 여러 특정 영역을 대상으로하는 SQL select 문

또한 모든 지점과 해당 지점의 대출 도서 금액을 모두 동시에 표시하는 방법이 필요합니다. 아무도 이걸로 도와 주면 놀라운 일 이겠지, 고마워!

select count(bookLoans.bookID) from bookLoans 
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID 
where libraryBranches.branchName = 'Sharpstown' 

답변

0

나는 무엇을 하려는지 확실하지 않지만 대답하려고 노력할 것입니다.

select libraryBranches.branchName, count(bookLoans.bookID) from bookLoans 
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID 
where libraryBranches.branchName = 'Sharpstown' 
group by libraryBranches.branchName; 

는 모든 가지를 얻으려면 : 첫 번째 질문에 대한

, 당신은 요청의 마지막에 당신의 "선택"의 BRANCHNAME를 추가하고 "에 의해 그룹의"를 추가해야 결과, 그냥 "부분"을 제거하십시오. 필요할 경우 끝에 "주문"을 추가 할 수 있습니다.

select libraryBranches.branchName, count(bookLoans.bookID) from bookLoans 
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID 
group by libraryBranches.branchName 
order by libraryBranches.branchName; 
+0

당신은 신 가운데 있습니다. 정말 고마워요. 이것은 내 질문에 완벽하게 대답했다. –

0

그냥 사용 그룹에 의해 : "지점 이름"과 같은 ... "대출 책 수" "다음 지점".. "대출 책 수"

코드 찾고

결과 like :

select count(bookLoans.bookID), libraryBranches.branchName from bookLoans 
inner join libraryBranches on bookLoans.lbID = libraryBranches.lbID 
Group by libraryBranches.branchName