Need help with mySQL statement

Status
Not open for further replies.

Sridhar_Rao

In the zone
I need help with SQL statement. Here is the structure of the table

+-------+---------------+
| slno | labno |
+-------+---------------+
| 1 | 5 |
+-------|---------------|
| 1 | 6 |
+-------|---------------|
| 2 | 7 |
+-------|---------------|
| 3 | 8 |
+-------|---------------|
| 3 | 9 |
+-------|---------------|
| 3 | 10 |
+-------|---------------|
| 4 | 11 |
+-------|---------------|

I need the output something like this:

+---------+---------+
| times | Nos |
+---------+---------+
| 3 | 1 | a*
+---------+---------+
| 2 | 1 | b*
+---------+---------+
| 1 | 2 | c*
+---------+---------+

a* i.e number of cases where slno is present 3 times (e.g slno 3 is present thrice and it is the only slno to be present thrice)
b* i.e number of cases where slno is present 2 times (e.g slno 1 is present twice and it is the only slno to be present twice)
c* i.e number of cases where slno is present once (e.g slno 2 & 4 are present only once and only two slno are present once)
 
Status
Not open for further replies.
Top Bottom