0

I'm trying to execute mssql query but its showing error.The same query I executed in MySQL its working fine.

The Query is:

SELECT tst_flow_name, tst_flow_desc,COUNT(tst_flow) tot 
FROM test_flow_details  
LEFT OUTER JOIN tst_flow ON tst_flow_name=tst_flow 
                        AND test_flow_details.project=tst_flow.project 
WHERE  test_flow_details.project='JupiterQA'

ERROR IS:

Column 'test_flow_details.tst_flow_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

How can I execute the MSSQL query without error.

juergen d
  • 201,996
  • 37
  • 293
  • 362
user3114967
  • 639
  • 5
  • 15
  • 38

1 Answers1

1

You can't mix normal column selects with aggregate function call like count().

Group by the columns you want to be unique and then you can add count()

SELECT tst_flow_name, tst_flow_desc, COUNT(*) tot 
FROM test_flow_details  
LEFT OUTER JOIN tst_flow ON tst_flow_name=tst_flow 
                        AND test_flow_details.project=tst_flow.project 
WHERE  test_flow_details.project='JupiterQA'
GROUP BY tst_flow_name, tst_flow_desc
juergen d
  • 201,996
  • 37
  • 293
  • 362