SELECT count (expscore) as count, sum (expscore) as sum, max (expscore) as max, min (expscore) as min, round
(Avg (EXPSCORE) * 1000)/1000 as avg, a. EXPACTID, B. teachercode, B. expname, c. classid, a. scoresubmit, a. scoreverify, c. schoolid
FROM expscore a, EXPACTIVATED B, schoolmajorclass c
Where a. expactid = B. expactid and B. schclassid = c. schclassid
Group by a. EXPACTID, B. teachercode, B. expname, c. classid, a. scoresubmit, a. scoreverify, c. schoolid
This is an SQL statement created for a view. The view creation statement is omitted.
When Hibernate's Reverse Engineering is used to automatically generate the Hibernate ing file, two class files are generated because the view does not have a primary key, and one class file is another Id, to use the decimal point and control the digits of the decimal point, I use the following method:
1. When an attempt is created, round (avg (EXPSCORE) * 1000)/1000 as avg is used to control the number of decimal places;
2. Modify the attributes in the generated ***. hbm. xml file, for example
<Key-property name = "avg" type = "java. lang. Long">
<Column name = "AVG" precision = "22" scale = "0"/>
</Key-property>
To:
<Key-property name = "avg" type = "java. lang. Double">
<Column name = "AVG" precision = "22" scale = "3"/>
</Key-property>
3. Modify the class file of the primary key id. The variable declared as Long is automatically generated and changed to the Double type.
4. Do not forget to add the new *. hbm. xml configuration file in Hibernate. cfg. xml.