<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" 
	"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

<jasperReport name="GroupReport" pageWidth="565" pageHeight="842" columnWidth="545" 
	leftMargin="10" rightMargin="10" topMargin="30" bottomMargin="30">

	<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" 
		isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" 
		pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false" />

	<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" 
		isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" 
		pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false" />
	<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" 
		isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" 
		pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false" />

	<parameter name="Title" class="java.lang.String"></parameter>
	<parameter name="BaseDir" class="java.io.File"></parameter>

	<queryString>
		<![CDATA[select first_name, last_name, city, state, email, age, 
		count(b.order_id) as no_order from sample.customer as a inner join 
		sample.customer_order as b on (a.customer_id=b.customer_id) 
		group by first_name, last_name, city, state, email, age order by state]]>
	</queryString>
	<field name="first_name" class="java.lang.String"></field>
	<field name="last_name" class="java.lang.String"></field>
	<field name="city" class="java.lang.String"></field>
	<field name="state" class="java.lang.String"></field>
	<field name="email" class="java.lang.String"></field>
	<field name="age" class="java.lang.Integer"></field>
	<field name="no_order" class="java.lang.Integer"></field>

	<group name="CustomerGroup" minHeightToStartNewPage="60">
		<groupExpression>
			<![CDATA[$F{state}]]>
		</groupExpression>
		<groupHeader>
			<band height="45">
				<textField>
					<reportElement mode="Opaque" x="0" y="4" width="520" 
						height="15" backcolor="#c0c0c0" />
					<textElement>
						<font reportFont="Arial_Bold" />
					</textElement>
					<textFieldExpression class="java.lang.String">
						<![CDATA["Customers in the state of " + $F{state}]]>
					</textFieldExpression>
				</textField>
				<line>
					<reportElement x="0" y="19" width="520" height="1" />
					<graphicElement />
				</line>
				<rectangle>
					<reportElement x="0" y="25" width="515" height="15" 
						forecolor="#333333" backcolor="#333333" />
					<graphicElement />
				</rectangle>
				<staticText>
					<reportElement mode="Opaque" x="0" y="25" width="130" 
						height="15" forecolor="#ffffff" backcolor="#333333" />
					<textElement textAlignment="Left">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[Name]]>
					</text>
				</staticText>
				<staticText>
					<reportElement mode="Opaque" x="130" y="25" width="130" 
						height="15" forecolor="#ffffff" backcolor="#333333" />
					<textElement textAlignment="Left">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[City]]>
					</text>
				</staticText>

				<staticText>
					<reportElement mode="Opaque" x="260" y="25" width="150" 
						height="15" forecolor="#ffffff" backcolor="#333333" />
					<textElement textAlignment="Left">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[Email]]>
					</text>
				</staticText>

				<staticText>
					<reportElement mode="Opaque" x="410" y="25" width="30" 
						height="15" forecolor="#ffffff" backcolor="#333333" />
					<textElement textAlignment="Left">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[Age]]>
					</text>
				</staticText>

				<staticText>
					<reportElement mode="Opaque" x="440" y="25" width="80" 
						height="15" forecolor="#ffffff" backcolor="#333333" />
					<textElement textAlignment="Left">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[No. of Orders]]>
					</text>
				</staticText>

			</band>
		</groupHeader>
		<groupFooter>
			<band height="20">
				<line>
					<reportElement x="0" y="1" width="515" height="1" />
					<graphicElement />
				</line>
				<staticText>
					<reportElement x="400" y="0" width="60" height="15" />
					<textElement textAlignment="Right">
						<font reportFont="Arial_Bold" />
					</textElement>
					<text>
						<![CDATA[Number of customers :]]>
					</text>
				</staticText>
				<textField>
					<reportElement x="460" y="0" width="30" height="15" />
					<textElement textAlignment="Right">
						<font reportFont="Arial_Bold" />
					</textElement>
					<textFieldExpression class="java.lang.Integer">
						<![CDATA[$V{CustomerGroup_COUNT}]]>
					</textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>

	<title>
		<band height="50">
			<line>
				<reportElement x="0" y="0" width="520" height="1" />
				<graphicElement />
			</line>
			<textField isBlankWhenNull="true">
				<reportElement x="0" y="10" width="445" height="30" />
				<textElement textAlignment="Left">
					<font reportFont="Arial_Normal" size="22" />
				</textElement>
				<textFieldExpression class="java.lang.String">
					<![CDATA[$P{Title}]]>
				</textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band></band>
	</pageHeader>
	<columnHeader>
		<band></band>
	</columnHeader>

	<detail>
		<band height="20">
			<textField>
				<reportElement x="0" y="4" width="130" height="15" />
				<textElement textAlignment="Left" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{last_name} + ", " + $F{first_name}]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="130" y="4" 
					width="130" height="15" />
				<textElement />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{city}]]>
				</textFieldExpression>
			</textField>

			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="260" y="4" 
					width="150" height="15" />
				<textElement />
				<textFieldExpression class="java.lang.String">
					<![CDATA[$F{email}]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="410" y="4" 
					width="30" height="15" />
				<textElement textAlignment="Center" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[String.valueOf($F{age})]]>
				</textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="440" y="4" 
					width="80" height="15" />
				<textElement textAlignment="Center" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[String.valueOf($F{no_order})]]>
				</textFieldExpression>
			</textField>
			<line>
				<reportElement positionType="Float" x="0" y="19" 
					width="520" height="1" forecolor="#808080" />
				<graphicElement />
			</line>
		</band>
	</detail>
	<pageFooter>
		<band height="40">
			<line>
				<reportElement x="0" y="10" width="520" height="1" />
				<graphicElement />
			</line>
			<textField>
				<reportElement x="200" y="20" width="85" height="15" />
				<textElement textAlignment="Right" />
				<textFieldExpression class="java.lang.String">
					<![CDATA["Page " + String.valueOf($V{PAGE_NUMBER})]]>
				</textFieldExpression>
			</textField>
			<textField evaluationTime="Report">
				<reportElement x="285" y="20" width="75" height="15" />
				<textElement textAlignment="Left" />
				<textFieldExpression class="java.lang.String">
					<![CDATA[" of " + String.valueOf($V{PAGE_NUMBER})]]>
				</textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="35">
			<textField isStretchWithOverflow="true">
				<reportElement x="175" y="20" width="165" height="15" />
				<textElement textAlignment="Center">
					<font reportFont="Arial_Italic" />
				</textElement>
				<textFieldExpression class="java.lang.String">
					<![CDATA["There were " + 
			String.valueOf($V{REPORT_COUNT}) + 
			"  customer records on this report."]]>
				</textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>