MySQL Forums
Forum List  »  Views

Subquery with table like parameter
Posted by: Jose Valle
Date: July 19, 2013 01:05PM

Hi, this is my first ask.

I have some troubles with a query, I need return the values of multiple subquerys,

My database has multimple tables with different information, but I need return a global id, so , in another table (reports_by_type) I save the name of table and the ID of the register of each one, and return the ID of (reports_by_type)


This is my original query

select a.table as table, a.date as date, count(*) as reports from reports_by_type.a group by a.table, a.date

I only group and return the count of reports by date and type


I need to add two values more... Like this but doesn´t work

select a.table as table, a.date as date, count(*) as reports,

(SELECT count(*) FROM {table} WHERE column_x= some_a) as some_a,
(SELECT count(*) FROM {table} WHERE column_x= some_b) as some_b

from reports_by_type.a group by a.table, a.date


Any idea for solve this?
thank for all

Options: ReplyQuote


Subject
Views
Written By
Posted
Subquery with table like parameter
5138
July 19, 2013 01:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.