tags:

views:

82

answers:

3

I have the following query:

select MIN(q.a), * FROM 
   (
     sub-query1
   ) as q
   UNION
   sub-query2

How can I return the number of elements in query1 as a row of master-query?


If i use count (*) i´ve only the count

CountElementSub-Query1

i need some like that

rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
rowA, rowB, rowC, CountElementSub-Query1
A: 

EDIT: -- Owner comment moved to question --

A: 

Can you use a subquery as a column definition in your select?

Michael Todd
+1  A: 

You're looking for a groupwise min/max:

http://jan.kneschke.de/projects/mysql/groupwise-max/

NeuroScr