我在 MySQL 中有下表,
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+
| ServiceCode | ser_count | FirstName | LastName | PatientID | HealthCardNumber | DateOfBirth | Gender |
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+
| AAAA | 1 | krishna | Mangeter | 1 | ABC123 | 1982-02-02 | M |
| BBBB | 4 | Pinthna | Paratter | 2 | KBC123 | 1981-02-02 | M |
| IIII | 2 | Pinthna | Paratter | 2 | KBC123 | 1981-02-02 | M |
| AAAA | 1 | Pinthna | Paratter | 2 | KBC123 | 1981-02-02 | M |
| CCCC | 1 | Pinthna | Paratter | 2 | KBC123 | 1981-02-02 | M |
| BBBB | 3 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |
| AAAA | 2 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |
| AAAA | 1 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |
| BBBB | 2 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |
| BBBB | 2 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |
| GGGG | 1 | Manshna | Bituater | 14 | MKO123 | 1982-02-02 | M |
| FFFF | 1 | Manshna | Bituater | 14 | MKO123 | 1982-02-02 | M |
| IIII | 3 | Manshna | Bituater | 14 | MKO123 | 1982-02-02 | M |
| GGGG | 1 | Bahshna | Vitueter | 15 | ZXS123 | 1982-02-02 | F |
| IIII | 1 | Krishhn | Ishqeter | 16 | VGT123 | 1987-02-02 | M |
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+
我想要上表中的前三名ser_count
&ServiceCode
并且PatientID
想要水平显示它们,如下所示。我尝试在 MySQL 提示符下使用存储过程,但它失败了。另外我不知道存储过程在 iReport/jasperserver 中是否有效。
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+------------------------+
| ServiceCode | ser_count | FirstName | LastName | PatientID | HealthCardNumber | DateOfBirth | Gender |Description |
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+------------------------+
| AAAA | 1 | krishna | Mangeter | 1 | ABC123 | 1982-02-02 | M |(1)AAAA |
| BBBB | 4 | Pinthna | Paratter | 2 | KBC123 | 1981-02-02 | M |(4)BBBB (2)IIII (1)AAAA |
| BBBB | 3 | Pelahna | Kumatter | 3 | SDF123 | 1984-02-02 | M |(3)BBBB (2)AAAA (2)BBBB |
| GGGG | 1 | Manshna | Bituater | 14 | MKO123 | 1982-02-02 | M |(3)IIII (1)FFFF (1)GGGG |
| GGGG | 1 | Bahshna | Vitueter | 15 | ZXS123 | 1982-02-02 | F |(2)GGGG |
| IIII | 1 | Krishhn | Ishqeter | 16 | VGT123 | 1987-02-02 | M |(1)IIII |
+-------------+-----------+-----------+----------+-----------+------------------+-------------+--------+------------------------+