Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
qwerty1234
Starting Member
13 Posts |
Posted - 2011-12-04 : 10:56:33
|
| I want to save this command as a view:select branch_id, POSITION, first_name, surname, start_salary, ((start_salary*30)*4) from staff_table group by branch_id, POSITION; i tried create view salary_report as select branch_id, posistion, first_name, surname, start_salary, ((start_salary*30)*4) monthly_sal from staff_table group by branch_id, POSITION; however it come back with errors saying that it shouln't be a group by expression. is there a way round this? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-12-04 : 11:34:30
|
| Any columns in your SELECT list (or in an expression in SELECT list) which don't appear in your GROUP BY clause must be aggregated in some way. ie MIN, MAX, AVG, etc...Get your statement working as just a SELECT first - when you have that working then you can add the CREATE VIEW...AS code.Be One with the OptimizerTG |
 |
|
|
qwerty1234
Starting Member
13 Posts |
Posted - 2011-12-04 : 12:26:40
|
| Thanks |
 |
|
|
|
|
|
|
|