sql - Joining a nested mysql query with field from another table -


i have table integers , parameters:

date timestamp 123  2013-07-22 16:33:17 123  2013-07-22 16:34:47 234  2013-07-20 16:33:15 332  2013-07-24 16:33:37 422  2013-07-21 10:13:11 422  2013-07-22 14:53:12 

and run following query number of distinct data choosing , random piece of distinct data:

select count(distinct(data)) count, (select data data_table     date(timestamp) >= '2013/07/22' , date(timestamp) < '2013/07/23'     group data order rand() limit 1) data data_table     date(timestamp) >= '2013/07/22' , date(timestamp) < '2013/07/23' 

and get:

count  data 2      123 

or

count  data 2      422 

now have table, *text_table*, whith primary key data. looks this:

data  text 123   "hi" 234   "hey" 332   "bye" 422   "cya" 

i need query result of previous query, plus text:

count  data  text 2      123   "hi" 

or

count  data  text 2      422   "cya" 

i tried:

select text_table.text text, count(distinct(data_table.data)) count,     (select data data_table group data order rand() limit 1) data     data_table left outer join text_table on data_table.date = text_table.text 

but returns same text time, no matter data was.

i did info need.

select count(dt.date) count, dt.date, tt.text data_table dt join text_table tt on tt.date = dt.date group dt.date, tt.text 

now need filter data want.

like this,

select count(dt.date) count, dt.date, tt.text data_table dt join text_table tt on tt.date = dt.date dt.timestamp > '2013/07/22' , dt.timestamp < '2013/07/23' group dt.date, tt.text 

you can had top 1 first line

thanks, chico


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -