Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combined query with aggregates
Message
 
 
À
30/08/2012 13:16:43
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01551715
Message ID:
01552032
Vues:
41
>>>>Are you missing an alias for the derived table?
>>>>
>>>>It should work OK - what is your error?
>>>
>>>Oh my . . . I just discovered another problem that I have to deal with first. With my test data, the first query returns 1 record, the second returns 179, but when I combine them with the UNION I only get 19.Coincidentally, 19 is the number that should return when the rtastatus field is aggregated. I thought perhaps the WHERE clauses were causing this but that is not the case. I also changed the aliases in the second SELECT so they were not reused but that also made no difference. Any idea what gives? I was expecting 180 records.
>>
>>UNION and UNION ALL are two different things. This is a hint, I am not telling you more, but you should figure this out.
>
>Thanks Naomi. I got my handy dandy reference book out and looked that up. This is the first time I have run into the DISTINCT nature if the union clause.

I remember a few years ago I was helping to conduct interviews for SQL Server position with ASP.NET and VFP knowledge. One of the questions I was asking in the phone interview is to what is the difference between these two (I actually myself was asked that question before also).
About half of the applicants could not answer that simple question.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform