I am trying to get the count of all the feature and the feature name against an application by using MySQL query. Here is the query:
select t2.feature,count(t2.feature) as count from judge_task t1, approve t2 where t1.application_name='Retail Bank Portal' AND t2.gap_status=1 group by feature;
Here is the description of my tables:
Table judge_task
+------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| application_id | int | NO | | NULL | |
| application_name | varchar(50) | YES | | NULL | |
| feature_id | int | NO | | NULL | |
| feature_name | varchar(50) | YES | | NULL | |
| task_type | int | NO | | NULL | |
Table approve
+------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| feature | varchar(500) | NO | | 0 | |
| gap_status | int | NO | | 3 | |
+------------------+--------------+------+-----+---------+----------------+
There is no relationship like foreign key between both the tables. The database was designed by someone else and it can not be updated now as the application is almost completed. Updating the database will disturb the whole application design.
Here is the result of the query:
+---------+-----+
| feature | app |
+---------+-----+
| S3 | 175 |
| Login | 875 |
+---------+-----+
The original count are as follows:
S3 = 1,
Login = 5
I am not getting the exact query to get my results. Would you please suggest me a correction to my query? How should I update it to get my results? Thanks a lot Update 1
sample data for judge_task is here
| 100173 | 4 | Retail Bank Portal | 16 | Login | 1 |
| 100203 | -1 | Retail Bank Portal | 16 | Login | 2 |
| 100204 | 4 | Retail Bank Portal | 19 | Bill Pay | 2 |
| 100205 | -1 | Retail Bank Portal | 16 | Login | 2 |
| 100206 | -1 | Retail Bank Portal | 16 | Login | 2 |
| 100207 | -1 | Retail Bank Portal | 16 | Login | 2 |
| 100208 | -1 | Retail Bank Portal | 16 | Login | 2 |
| 100209 | -1 | Retail Bank Portal | 22 | S3 | 2 |
Sample data for approve
| 59 | Login | 1 |
| 60 | Login | 1 |
| 115 | Login | 1 |
| 116 | Login | 1 |
| 117 | Login | 3 |
| 118 | Login | 3 |
| 119 | Login | 3 |
| 120 | Login | 3 |
| 121 | Login | 3 |
| 122 | Login | 3 |
| 123 | Login | 3 |
| 124 | Login | 3 |
| 125 | Login | 3 |
| 126 | Login | 3 |
| 127 | Login | 3 |
| 128 | Login | 1 |
| 129 | S3 | 1 |
+-----+-------------------------+------------+
I have updated the table definitions according to sample data removing the irrelevant columns. Thanks
Update
One thing I forget to mention that the data has to be selected from approve table and just the application name is to be selected from judge_task.