0

I'm tried to execute the below query in MSSQL 2008 R2,but its throwing error. THE QUERY IS:

    SELECT (n_artifactType+(' '+ n_actionPerformed)) AS actionperformed, 
    COUNT(n_actionPerformed) total FROM notifications WHERE   n_project='JupiterQA'
    GROUP BY actionperformed order by n_actionPerformed;

ERROR IS:

Msg 207, Level 16, State 1, Line 1
Invalid column name 'actionperformed'.

Using 'actionperformed' as alias name even though its throwing error. How can I execute above query without error.

1
  • please include your table column names Commented Jan 30, 2015 at 6:00

2 Answers 2

2

By the looks of it actionperformed is an alias name and not an actual table field (or expression of), which is required by a group by clause.

Suggest group by (n_artifactType+(' '+ n_actionPerformed)) instead.

Interestingly order by would however be happy with an alias.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm using DATE(n_received) in MYSQL and I need equivalent in MSSQL.
Sorry not sure i am following
In MSSQL you could use convert, like this select CONVERT(varchar, GETDATE(),111); to convert a DateTime to a formatted date.
0

The error is in group by section of the query, group by will not work with alias change it to actual expression i.e.(n_artifactType+(' '+ n_actionPerformed))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.