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 |
|
phobos300
Starting Member
3 Posts |
Posted - 2011-06-08 : 09:51:41
|
Hi all,I have a question regarding select query:Is it possible to e.g sum keys XX and YY ?I need to sum those 2 values without using the something/something_else again.The query below is giving error:[Error Code: 1054, SQL State: 42S22] Unknown column 'something' in 'field list'selectsomething as XX,something_else as YY,XX+YY as ZZfrom sometable thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-06-08 : 09:58:19
|
[code]select XX, YY, XX+YY as ZZfrom(select something as XX, something_else as YYfrom sometable) t[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
phobos300
Starting Member
3 Posts |
Posted - 2011-06-08 : 10:34:44
|
| Thanks khtanbut your advise doesn't work |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-06-08 : 10:51:05
|
why ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
phobos300
Starting Member
3 Posts |
Posted - 2011-06-08 : 10:55:41
|
| Its giving me an error: [Error Code: 1248, SQL State: 42000] Every derived table must have its own alias |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-06-08 : 10:58:05
|
SQLTeam.com is on Microsoft SQL Server. For MySQL, please post at dbfourms.com or forums.mysql.com KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|