January 21, 2011 at 8:50 am
Hi! I can´t understand why it doesnt work!.
select count (codaux) from
(select codaux,nomaux from aqua.softland.cwtauxi)
except
(select codaux,nomaux from 0718.softland.cwtauxi)
i get:
'Incorrect syntax near the keyword 'except'.'
thanks in advance.
January 21, 2011 at 8:58 am
select count (codaux) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi)
Do you understand?
January 21, 2011 at 10:07 am
skcadavre (1/21/2011)
select count (codaux) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi)
Do you understand?
hi!.
Since i am getting a sintax error i thought that no other info was needed.
But if it´s needed i will provide it.
I have to tables in diferent databases.
The tables are identical to each other.
The tables are:
- aqua.softland.cwtauxi
- 0718.softland.cwtauxi
I need to retrieve the resulting amount of rows from the query;
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi)
The above query does exactly what i need.
So then i started looking information to acomplish what i want.
And i found this:
And got:
select count (codaux) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi)
But it doesnt work.
Maybe i got wrong the info.
thanks ind advance.
---------------
I got the info wrong the above query is for firebird.
My bad.
January 21, 2011 at 10:30 am
Just assign an alias to your nested query expression and it will be OK
select count (*) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi) as x
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 21, 2011 at 10:42 am
ALZDBA (1/21/2011)
Just assign an alias to your nested query expression and it will be OK
select count (*) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi) as x
thanks it worked.!
Now,..can you explain why do you hace to use 'as'?
January 21, 2011 at 11:12 am
igngua (1/21/2011)
ALZDBA (1/21/2011)
Just assign an alias to your nested query expression and it will be OK
select count (*) from
(select codaux,nomaux from aqua.softland.cwtauxi
except
select codaux,nomaux from 0718.softland.cwtauxi) as x
thanks it worked.!
Now,..can you explain why do you hace to use 'as'?
The keyword 'as' is optional. You can assign the alias without 'as'. Some would consider using it being more descriptive, others don't. I think the most important part is to be consistent within the code.
January 22, 2011 at 4:49 am
Lutz covered it perfectly :w00t:
Further info can be found in books online topic "Using Table Aliases"
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 24, 2011 at 9:35 am
Perhaps the OP meant why an alias is required ?
January 24, 2011 at 2:37 pm
books online topic "FROM (Transact-SQL) " states
[ FROM { <table_source> } [ ,...n ] ]
<table_source> ::=
{
table_or_view_name [ [ AS ] table_alias ] [ <tablesample_clause> ]
[ WITH ( < table_hint > [ [ , ]...n ] ) ]
| rowset_function [ [ AS ] table_alias ]
[ ( bulk_column_alias [ ,...n ] ) ]
| user_defined_function [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]
| OPENXML <openxml_clause>
| derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ]
| <joined_table>
| <pivoted_table>
| <unpivoted_table>
| @variable [ [ AS ] table_alias ]
| @variable.function_call ( expression [ ,...n ] ) [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]
}
so the alias is mandatory for a derived table.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 24, 2011 at 5:16 pm
That clears it all!
thanks!
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply