database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
ㆍMS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MS-SQL Q&A 4022 게시물 읽기
No. 4022
다음의 합계를 구하는데 잘 안되네요..;;
작성자
이정규(i6020345)
작성일
2008-01-31 11:23
조회수
3,080

SELECT case

  when user_grade = 'basic' then image_price * buy_count

  when user_grade = 'bronze' then image_price * buy_count + ( product_price * 0.03 )

  when user_grade = 'silver' then image_price * buy_count + ( product_price * 0.05 )

  when user_grade = 'gold' then image_price * buy_count + ( product_price * 0.1 )

  when user_grade = 'premium' then image_price * buy_count + ( product_price * 1 )

  else image_price * buy_count end

 FROM         테이블명

 WHERE user_idx = '44'



이 결과의 합을 구하고싶은데요....도움좀 부탁드립니다.

이 글에 대한 댓글이 총 1건 있습니다.
select sum(prc)
from
( SELECT
    prc = case
     when user_grade = 'basic'   then image_price * buy_count
     when user_grade = 'bronze'  then image_price * buy_count + ( product_price * 0.03 )
     when user_grade = 'silver'  then image_price * buy_count + ( product_price * 0.05 )
     when user_grade = 'gold'    then image_price * buy_count + ( product_price * 0.1 )
     when user_grade = 'premium' then image_price * buy_count + ( product_price * 1 )
     else image_price * buy_count end
   
  FROM         테이블명
  WHERE user_idx = '44'
) x
.님이 2008-01-31 12:00에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
4026조회시에 문제가 생겼어요 [2]
부탁드립니다 .
2008-02-01
3142
4025sql 프로필러에 관해서 질문 드립니다.
정명규
2008-02-01
3173
4023[초보질문]쿼리문 실패시 로그에 남나요? [1]
힘들어요
2008-01-31
3252
4022다음의 합계를 구하는데 잘 안되네요..;; [1]
이정규
2008-01-31
3080
4021union에 관해서 질문드립니다. [1]
정명규
2008-01-30
3054
4020수정에 관해서 질문 드립니다. [1]
정명규
2008-01-30
2842
4019프로시저내에서 XP_CMDSHELL을 사용한후의 오류검출은 어떻게? [1]
안수철
2008-01-29
3394
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다