๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์‹œ๋„/๊ตญ๋น„์ง€์›

[D+79] ๊ณผ์ •ํ‰๊ฐ€ํ˜• ์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ : ํšŒ์›๋งค์ถœ์กฐํšŒํ™”๋ฉด(sale.jsp) ๊ตฌํ˜„

by ๐Ÿ‡๋ฐ•๋ด‰๋ด‰๐Ÿ‡ 2023. 1. 10.

 

 

๊ตญ๋น„์ง€์› D+79

๊ณผ์ •ํ‰๊ฐ€ํ‰ ์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ

- ํšŒ์›๋งค์ถœ์กฐํšŒํ™”๋ฉด(sale.jsp) ๊ตฌํ˜„ -

 


 

ํšŒ์›๋งค์ถœ์กฐํšŒํ™”๋ฉด(sale.jsp) ๊ตฌํ˜„

ํšŒ์›๋งค์ถœ์กฐํšŒ๋Š” ํšŒ์›ํ…Œ์ด๋ธ”๊ณผ ํšŒ์›๋งค์ถœํ…Œ์ด๋ธ”์„ ์กฐํ•ฉํ•ด ํ™”๋ฉด์— ๋„์šฐ๋Š” ๊ฒƒ์œผ๋กœ join์„ ํ•ด์•ผ ํ•œ๋‹ค.

 

์ด๋•Œ ๋‘ ํ…Œ์ด๋ธ”๊ฐ„์— ๊ณตํ†ต์œผ๋กœ ๊ฒน์น˜๋Š” ์ •๋ณด๋งŒ ํ™”๋ฉด์— ๋„์›Œ์ค„ ์˜ˆ์ •์ด๊ธฐ ๋•Œ๋ฌธ์— inner join์œผ๋กœ ๋ฐ์ดํ„ฐ ์ •๋ณด๋ฅผ ๋Œ์–ด์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

 

• sale.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>

<%@ page import="DBPKG.DBConnection" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ํšŒ์›๋งค์ถœ์กฐํšŒ</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
	<header>
		<div>
			<h2>์‡ผํ•‘๋ชฐ ํšŒ์›๊ด€๋ฆฌ ver 1.0</h2>
		</div>
	</header>
	
	<nav>
		<div>
			<a href="register.jsp">ํšŒ์›๋“ฑ๋ก</a>
			<a href="inquiry.jsp">ํšŒ์›๋ชฉ๋ก์กฐํšŒ/์ˆ˜์ •</a>
			<a href="sale.jsp">ํšŒ์›๋งค์ถœ์กฐํšŒ</a>
			<a href="index.jsp">ํ™ˆ์œผ๋กœ</a>
		</div>
	</nav>
	
	<section>
		<div>
			<h3>ํšŒ์›๋งค์ถœ์กฐํšŒ</h3>
			<table border="1" style="width: 500px">
				<tr>
					<th>ํšŒ์›๋ฒˆํ˜ธ</th>
					<th>ํšŒ์›์„ฑ๋ช…</th>
					<th>๊ณ ๊ฐ๋“ฑ๊ธ‰</th>
					<th>๋งค์ถœ</th>
				</tr>
				
<% 
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;

String custno = "";
String custname = "";
String grade = "";
String sale = "";

String sql = "select member.custno, member.custname, member.grade, sum(money.price) " + 
				"from member_tbl_02 member inner join money_tbl_02 money " + 
				"on member.custno = money.custno " + 
				"group by member.custno, member.custname, member.grade " + 	
				"order by sum(money.price) desc";

try
{
	conn = DBConnection.getConnection();
	stmt = conn.createStatement();
	rset = stmt.executeQuery(sql);
	
	while(rset.next())
	{
		custno = rset.getString(1);
		custname = rset.getString(2);
		grade = rset.getString(3);
		sale = rset.getString(4);
		
		switch(grade)
		{
		case "A":
			grade = "VIP";
			break;
		case "B":
			grade = "์ผ๋ฐ˜";
			break;
		case "C":
			grade = "์ง์›";
			break;
		default:
			grade = "๋ฏธ์ •";
			break;
		}
%>

				<tr>
					<td><%= custno %></td>
					<td><%= custname %></td>
					<td><%= grade %></td>
					<td><%= sale %></td>
				</tr>

<%
	}
}

catch(Exception e)
{
	System.out.println("[ERROR] " + e.getMessage());
	e.printStackTrace();
}
%>
				
			</table>
		</div>
	</section>
	
	<footer>
		<div>
			<h4>HRDKOREA Copyright@2016 All rights reserved. Human Resources Development Service of Korea</h4>
		</div>
	</footer>
</body>
</html>

 

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€