티스토리 뷰
-- 테이블 생성.
/*
결과가 아래와 같게.
code | good1 | good2 | good3
001 | 2개 | 1개 | 1개
002 | 1개 | 0개 | 1개
*/
create table good_out
(
code varchar(100) null,
goodname varchar(100) null
)
go
-- 데이타 입력.
insert into good_out
select '001','good1' union all
select '001','good2' union all
select '001','good1' union all
select '001','good3' union all
select '002','good1' union all
select '002','good3'
-- 테이블 및 데이타 확인.
select * from good_out
-- - 정답 -
declare @EA varchar(2);
set @EA = '개'
SELECT code
, count(case when goodname = 'good1' then goodname + @EA else null end) as 'good1'
, count(case when goodname = 'good2' then goodname + @EA else null end) as 'good2'
, count(case when goodname = 'good3' then goodname + @EA else null end) as 'good3'
FROM good_out
group by code
'프로그래밍 > MSSQL' 카테고리의 다른 글
현재 테이블에서 사용중인 프로시저 확인하기 (0) | 2012.09.21 |
---|---|
해당 DB(데이터베이스)를 사용중이라 삭제할 수 없을때. (0) | 2012.09.13 |
특정사용자 테이블보기, 유저테이블 보기. (0) | 2012.08.31 |
WITH문으로 쿼리를 임시테이블이나 View처럼 사용하자. (0) | 2012.08.14 |
WITH (NOLOCK) (0) | 2012.08.14 |
- Total
- Today
- Yesterday
- jQuery
- 자바스크립트
- jQuery Mobile
- MSSQL
- Ajax
- css3
- 제이쿼리
- html5
- WCF
- 저장프로시저
- rowspan
- JavaScript
- Mobile
- Chart
- drag&drop
- IE
- WebApi
- CSS
- JS
- 프로시저
- ASP.NET
- SVG
- json
- workbook
- Excel
- jquery chart
- radius
- 셀렉터
- grid
- Style
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |