| Author |
Topic |
|
kazineel
Starting Member
16 Posts |
Posted - 2011-06-20 : 08:10:09
|
| Hello Guys,Would you please help me about this sql? I have this sql and the result is SELECT TestPlan_id,status, COUNT(TestCase_id) as CntFROM TestExecutionWHERE Lab_id LIKE '%1%' AND TestPlan_id LIKE '%1%' AND Test_iteration_id LIKE '%1%' AND TestCycle_id LIKE '%2%'AND status IN ('P','N','F','U','X','B','Def')GROUP BY TestPlan_id, Category_id, Sub_category_id, Tester_Id,statusThe Result is like thisTestPlan_id status Cnt1 N 21 P 181 P 171 P 141 Def 41 P 741 Def 4But I want to display the result like this TestPlan_id P N Def1 2 1 42 5 5 6Total 7 6 10would you please help me?THanksKazi |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-20 : 08:18:46
|
| How do you get the result?You have 7 rows for TestPlan_id 1. Can guess how you get the def entry but that's about it.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
kazineel
Starting Member
16 Posts |
Posted - 2011-06-20 : 08:31:24
|
Is that possible to display Id 1 in on column then 2 another column like this wayquote: TestPlan_id P N Def1 2 1 42 5 5 6Total 7 6 10
|
 |
|
|
kazineel
Starting Member
16 Posts |
Posted - 2011-06-20 : 12:25:55
|
| Hello,I have made my sql, now I can display records like this wayTestPlan_id P N Def1 2 1 42 5 5 6Here is my update sqlSELECT TestExecution.TmatsLog_id AS ID, TestPlan.testPlanName AS TestPlan,Lab.name AS Lab,User.loginName AS Tester,sum(IF(TestExecution.status = 'P', 1, 0)) AS `P`,sum(IF(TestExecution.status = 'U', 1, 0)) AS `U`,sum(IF(TestExecution.status = 'Def', 1, 0)) AS `Def`,sum(IF(TestExecution.status = 'B', 1, 0)) AS `B`,sum(IF(TestExecution.status = 'X', 1, 0)) AS `X`,sum(IF(TestExecution.status = 'F', 1, 0)) AS `F`,sum(IF(TestExecution.status = 'N', 1, 0)) AS `N`FROM TestExecution,TestPlan,Lab,User WHERE TestCycle_id=5 AND User.id=Tester_Id AND Lab.id=Lab_id AND TestPlan.id=TestPlan_id AND retest_flag = 0 GROUP BY status,TestPlan_id order by TestPlan_idNow I want to calculate sum(IF(TestExecution.status = 'P', 1, 0)) AS `P` + sum(IF(TestExecution.status = 'U', 1, 0)) AS `U`can you tell me how to do this? |
 |
|
|
|
|
|