Buda
Buda

Reputation:

Mysql Count

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

Upvotes: 0

Views: 298

Answers (2)

NeuroScr
NeuroScr

Reputation: 322

You're looking for a groupwise min/max:

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

Upvotes: 1

Michael Todd
Michael Todd

Reputation: 17081

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

Upvotes: 0

Related Questions