854747	14300	is there a way i can make the case when test one of the results rather than running it twice?	select     orderid,     case when maxprice is null then 0 else maxprice end as maxprice from (     select         orderid = o.id,         maxprice = (select max(price) from orderlines ol                      where ol.orderid = o.id)     from orders o ) sub 	0.39406461302696
1091746	4948	how to concatenate values from mysql select	select group_concat(bar) from table group by foo; 	0.000272814978849137
1105463	1496	sqlite binding within string literal	select * from table where title like '%' || ? || '%'; 	0.668264382318105
1789296	8137	how to search for text in sql server when storing different languages	select      product_name  from      products  where      product_name collate sql_latin1_general_cp1_ci_ai like 'chateau' 	0.175175462166316
2170480	33202	joining multiple (4) tables in mysql	select employeename, positionname, groupname from employees e left join employeepositions ep on ep.employeeid = e.employeeid left join positions p on p.positionid = ep.positionid left join employeegroup eg on eg.groupid = e.groupid where e.employeeid = some_value 	0.0339471680315974
2175686	12857	inserting sum of 2 tables into a row	select   (select sum(data1) from firsttable where date=@date) firsttablesum,  (select sum(data2) from secondtable where date=@date) secondtablesum 	0
2434472	30931	sql: getting the full record with the highest count	select * from data inner join (select idnum, max(count) from data             group by idnum )sub on sub.idnum=data.idnum && sub.count=data.count 	0.000257160664760943
3376458	21363	php mysql sort by date (newest)	select * from articles order by time desc 	0.00524484320928315
3427456	12806	datetime implementation in php mysql	select time(fieldname) from tablename 	0.778618626584352
3533173	30867	mysql: how do i remove the first row?	select coalesce(unix_timestamp(date(p.published_at)),0) as 'day',         coalesce(sum(case when p.status = 2 then p.value end),0) as 'total_accepted',        coalesce(sum(case when p.status = 1 then p.value end),0) as 'total_open',        coalesce(sum(case when p.status = 3 then p.value end),0) as 'total_declined',        coalesce(sum(case when p.status !=0  then p.value end),0) as 'total_published' from posts as p where p.published_at is not null group by date(p.published_at); 	0.000407210015728105
4382462	31184	t-sql two where clauses on same column	select name, num from tbl where name in (     select name from tbl     where num in (10, 20)     group by name      having count(*) = 2  ) and num in (10, 20)  	0.00515843909698577
4448848	39690	sql server, selecting random item from table where id used across another table	select top 1 * from     root r         left join     rootitem ri         on             r.id = ri.rootid and             ri.accountid = @accountid where     r.private = 0 and     ri.id is null order by     newid() 	0
4834600	26001	fetching a table with unique or distinct values?	select count(distinct event_id) from   posts  where  user_id = '43'    and event_id is not null 	0.00162378768660878
4854987	40469	3 table joins one field from one table and one field from another	select c.city, t.time_slot  from cities c left join city_date d on d.city_id = c.id  left join city_time t on t.city_date_id = d.city_id and t.city_date_id = '1' 	0
4926247	13439	mysql/php determine lowest values in table with multiple value columns	select least(t.c_price1, t.c_price2) as lowest     from your_table t    where least(t.c_price1, t.c_price2) != 0.00 order by lowest    limit 5 	0
5181698	35763	how do i retrieve results from mysql where a timestamp is between 11pm yesterday and 11pm today?	select * from table where create_date  between concat_ws(' ',curdate(),'23:00:00') - interval 1 day  and concat_ws(' ',curdate(),'23:00:00') 	0
5210167	7383	collapse sql rows	select demotable.* from demotable left join demotable as prev on prev.id = demotable.id - 1 where demotable.name != prev.name 	0.071036995712693
5611126	4349	finding all polls that a specific user hasn't voted on yet	select *   from pools  where id not in (        select poolid          from votes         where userid = 142        ) 	0.000570755291526166
5611196	38103	group mysql subcategories and categories	select sc.title as subcat_title, c.title as cat_title      from subcategory as sc left join category as c        on c.id = sc.cid 	0.101167698288363
5874367	12306	ms access average after subtracting	select col3, format(avg([col2]-[col1]),"hh:mm:ss") as timediff from table1 group by col3; 	0.0181165096952671
6050224	17610	join query on multiple rows to search in	select u.id  from wp_users as u inner join wp_usermeta as umf on u.id = umf.user_id  inner join wp_usermeta as uml on u.id = uml.user_id  where umf.meta_key = 'first_name'      and umf.meta_value = 'myfirstname'     and uml.meta_key = 'last_name'      and uml.meta_value = 'dijkstra' 	0.0687933446680328
6260862	35630	select from view | order by not working	select convert(varchar,[date],103) as [date]                       ,[vouchertype]                       ,[billno]                       ,[debit]                       ,[credit] from [accountsledger] order by [accountsledger].[date] 	0.726889384762654
6296061	14481	mysql relational question. get results when m:n null	select username     from user u         inner join usergroup ug             on u.usergroup_usergroupid = ug.usergroupid          left join user_has_bar ub             on u.userid = ub.user_userid     where u.userage = 10         and u.location_locationid = 1         and ub.user_userid is null 	0.708928088396501
6442031	33051	query result reversing	select * from (select * from msg order by id desc limit 10) as requiredlimit order by id asc 	0.375614049315968
6879391	22498	mysql join with limit 1 on joined table	select c.*,       (select p.id, p.title         from products as p        where p.category_id = c.id        limit 1) from categories c 	0.0474990073553084
7516116	12616	sql - count and percent	select     count(i.id) as count    ,l.id    ,(     100.0 * count(i.id)      /       (       select count(i2.id)        from location l2       join item i2 on i2.locid = l2.id       where l2.id = l1.id      )    ) as percent    from location l    join item i on i.locid = l.id  where l.id in (36,38,39,40)  group by l.id 	0.0483250778609066
7845080	19812	combining columns	select t.ename, t.deptno, mx.sal as sal, mx.avg_sal as avg_sal from tbl t,    (select max(sal) as sal, avg(sal) as avg_sal, deptno    from tbl    group by deptno) mx where t.deptno = mx.deptno and t.sal = mx.sal 	0.0254989648024062
8026097	15264	sum of 2 tables query using subqueries	select     (select sum(`upload_bandwidth`) from `upload_facts` where `date`        between '2011-09-01' and '2011-09-30')     +     (select sum(`download_bandwidth`) from `download_facts` where `date`        between '2011-09-01' and '2011-09-30') as `total` 	0.0767804870190292
8149692	29552	using min() in multiple tables	select hotel_id, hotel_name, min(price) from region join region_contents     on regionname = <reqdname> and region.regionid = region_contents.regionid join prices     on region_contents.hotel_id = prices_hotel_id where end_date > now() group by hotel_id order by min(price) 	0.0816847304683261
8483413	19506	sql php recordset position	select count(id)+1 as rank from players where score>[yourplayerscore] 	0.0957064894899551
8736330	36017	sql result: non-empty categories	select   categories.name,   ... from   categories   inner join partcategories on partcategories.categoryid=categories.categoryid   inner join parts on partcategories.partid=parts.partid   inner join manufacturers on parts.manufacturerid=manufacturers.manufacturerid where   manufacturers.manufacturerid=<your chosen manufacturerid> 	0.13105752853811
9195644	21246	how to fetch only a value from mysql database?	select name from top_categories where top_categories.id = your_id   order by name asc  limit 0,1 	0
9347225	4078	mysql left join with three tables	select count(*) as match_count from clan_members c, roster_members r, match_players m where c.member_id = r.clan_member_id and r.id = m.roster_member_id and c.id = 123 	0.691463271531026
9631610	30078	mysql inner join 'unkown column'	select sql_calc_found_rows k_services.id, service_status, service_tourno, service_date, service_cxldate, service_difficultperiod, service_priority, service_currency, service_key_so, service_price_so, service_key_ok, service_price_cfm, service_supplement      from  k_services     join k_remarks on (k_remarks.remark_service = k_services.id and k_remarks.remark_type = 9)     where  k_services.service_market = 2      limit 0, 25 	0.614808931749942
9795921	6044	mysql query to get rows in a sphere (x, y, z coordinates)?	select x, y, z from reinforcements  where durability >= 1  and world=? and (pow((x-?),2)+pow((y-?),2)+pow((>-?),2))<pow(?,2) 	0.00206674994147226
9828273	9753	group and count in sql server 2008	select downloaddate, count(downloaddate) as totaldownloaded from yourtable group by downloaddate 	0.613912897596373
10390707	35254	php mssql_query errors when converting date and/or time from character string	select    dbo.bsc.bsc_id,   dbo.bsc.bsc_name,    dbo.bsc.bsc_owner,    case maxview.maxdate      when null then null      else datediff(m,convert(datetime, left(maxview.maxdate, 4)+ right(maxview.maxdate, 2) + '01', 121),getdate())    end  from dbo.bsc  left outer join (select bsc_id, max(dbo.bscdataset.dateperiod) as maxdate  from dbo.bscdataset group by bsc_id) maxview  on dbo.bsc.bsc_id = maxview.bsc_id; 	0.487668925708292
10412472	24830	query for "how many users submitted content each month"	select count(distinct(t1.uid)) from node t1 inner join node t2 on t2.uid = t1.uid and t2.created between date_add(now(), interval -2 month) and date_add(now(), interval -1 month) inner join node t3 on t3.uid = t1.uid and t3.created between date_add(now(), interval -3 month) and date_add(now(), interval -2 month) inner join node t4 on t4.uid = t1.uid and t4.created between date_add(now(), interval -4 month) and date_add(now(), interval -3 month) where t1.created between date_add(now(), interval -1 month) and now() 	0
10855884	3315	pivoting data in mysql. 	select     s.name,     avg(r.result) as average,     t1.result as test1,     t2.result as test2 from     students s,     results r,     results t1,     results t2 where     r.student_id = s.id and     t1.test_id = 1 and     t1.student_id = s.id and     t2.test_id = 2 and     t2.student_id = s.id group by s.id; + | name | average | test1 | test2 | + | john |      70 |    90 |    50 |  | jane |    82.5 |    70 |    95 |  + 	0.404310436230321
10975595	34905	select birthday upcoming month	select birthdaycolumn from yourtable where month(birthdaycolumn) = month(getdate()) 	0.00083777488060132
11024327	35045	need help joining a second table	select student_name,         city,         state,         request_date,         lat,         lng,         <<distance column>> as distance,         vendor.user_purchased from lesson_requests  inner join     (     select student_id, max(request_date) as max_request_date     from lesson_requests     where <<complex condition>>     group by student_name    ) as recent_student_lesson_request    on  lesson_requests.student_name = recent_student_lesson_request.student_name        and lesson_requests.request_date = recent_student_lesson_request.max_request_date left join vendor on v.user_purchased = lesson_requests.student_name where vendor.user_purchased <> 'abs_company'     and distance < blah; 	0.122565687620982
11075690	14298	count number of unique users which loggedin more than once	select website.websitename, count(*) from website  inner join ( select userid, websiteid, count(*) from loginrecord group by userid, websiteid having count(*) > 1) as t1 on t1.websiteid = website.websiteid group by website.websitename 	0
11173890	26455	eliminating null rows in tsql query	select [stuff] from  group_profile gp with (nolock)    inner join group_profile_type gpt with (nolock) on gp.group_profile_type_id = gpt.group_profile_type_id and gpt.type_code = 'fosterhome' and gp.agency_id = @agency_id and gp.is_deleted = 0    inner join group_profile mo with (nolock) on gp.managing_office_id = mo.group_profile_id    join payor_vendor pv on isnull(gp.payor_vendor_id, 'thisvaluewillneveroccur') = isnull(pv.payor_vendor_id, 'thisvaluewillneveroccur') ...etc... 	0.349169807287502
11221003	15580	does mysql accept order by "nothing" limit "all" when i only want to get number of results in a search query?	select count(*) from ... group by a, b, c having ... 	0.00583197955166278
11225821	7587	query selecting rows where data doesn't change	select     g.event,     min(g.selection) as selection_a,     max(g.selection) as selection_b from golf_matches as g group by g.event union all select     g.event,     max(g.selection),     min(g.selection) from golf_matches as g group by g.event order by 1, 2; 	0.0166371821767125
11612925	21985	sorting username	select * from `members` where username like 'bx%' order by length(username), username 	0.333662422511213
11875509	33785	mysql rank of more than one column of one user	select * from (select m.name,rank_level,rank_win  ,rank_loss from      (select @rank := @rank + 1 as rank_level,name,id from users order by level desc) m      inner join  (select @rankw := @rankw + 1 as rank_win,name,id          from users order by win desc) w on m.id=w.id      inner join  (select @rankl := @rankl + 1 as rank_loss,name,id          from users order by loss desc) l on m.id=l.id       , (select @rank := 0) m2,(select @rankw := 0) w2,(select @rankl := 0) l2 ) k where k.name= 'alan'; 	0
12392755	27469	"select distinct" query bringing back too many unique rows	select      p1.c_clm,     p1.c_sta_clm,     p1.whse_curr_row_ind,     p2.loaded from pearl_p.tltc900_clm_prsst p1 inner join (     select max(whse_load_ts) as loaded, c_clm     from  pearl_p.tltc900_clm_prsst     where whse_curr_row_ind not in('y')     group by c_clm ) p2     on p1.whse_load_ts = p2.loaded     and p1.c_clm = p2.c_clm where p1.whse_curr_row_ind not in('y') 	0.0328931775151799
12850893	9850	order by number of commas	select * from table order by length(areacodefield)-length(replace(areacodefield, ",", ""))) desc 	0.00317329329222777
13385755	39233	display unique data from two tables	select id, subid from tbla union  select id, subid from tblb 	0
13449609	21472	select the previous x rows	select * from image order by image_id desc limit (x-10), 10 	0.000163656826410143
14163188	25701	dynamic where clause with set number of columns	select * from table where isnull(@param1,field1)=field1 and isnull(@param2,field2)=field2 and isnull(@param3,field3)=field3 and isnull(@param4,field4)=field4 and isnull(@param5,field5)=field5 	0.0335043146500264
14388790	16087	sort posts by newest child's timestamp or own timestamp	select  *,         (         select  coalesce(max(cp.post_date), ct.post_date)         from    conversation_conversationpost cp         where   cp.thread_id = ct.id         ) as sort_date from    conversation_conversationthread ct order by         sort_date desc 	0
14441888	20788	more than one join mysql?	select * from sub_menu left join root_sub on sub_menu.id = root_sub.sub_id left join root_menu on root_sub.root_id = root_menu.id 	0.0837991158431074
14701296	25242	how to use max and top in sql query in oracle?	select id      , item      , quantity      , date   from (select id              , item              , quantity              , date           from your_table          order by quantity desc, date desc         ) where rownum = 1 	0.276251020446577
14739134	23598	sql query to find false negatives w.r.t data matching or entity resolution	select        t1.id,        t1.variable,        t1.value     from        table t1     where        exists ( select 1                    from t2                    where t2.id != t1.id                      and t2.variable == t1.variable                      and t2.value != t1.value) 	0.213532859867176
14934427	12017	returning a set of hstore values as a set of records of a table type	select   (populate_record(null::public.usr, logged_actions.row_data)).* from   audit.logged_actions where   audit.logged_actions.table_name = 'usr' 	0
15049688	11127	selecting the maximum bids overall	select userid, uname from user1  where userid in  (select bidder from bid group by bidder having count(bidder) =  (select max(c) from (select count(*) as c, bidder from bid group by bidder))); 	0.00119734864078261
15071002	18884	mysql divide two values from same column	select metalid,   max(case when currencyid = 1 then fixam end) /    max(case when currencyid = 2 then fixam else 1 end) output from fixes group by metalid 	0
15492646	1798	inner join with 3 tables	select  a.*, c.date from    album a         inner join album_photo b             on a.album_id = b.album_id         inner join photo c             on b.photo_id = c.photo_id where   c.nick = 'owner' and         (           select count(*)            from   album_photo d           where  b.album_id = d.album_id and                  d.nick = 'owner' and                  b.date >= d.date         ) <= 2 	0.602917904392728
15582528	21892	extract records from mysql based on results from other table	select t2.* from (     select u2 as value from table1      where u1 = :value and status = "confirmed"     union     select u1 as value from table1      where u2 = :value and status = "confirmed" ) as t1, table2 as t2 where t2.u1 = t1.value  or t2.u2 = t1.value order by t2.id 	0
15752167	5318	mysql subquery for max employee hours	select employee_id, sum(timediff(time_off, time_on)) as diff from tbl where year(time_on) = 2013     and month(time_on) = 3 group by employee_id 	0.00540207112934332
16071372	19953	sql select the available rooms by date cheking	select * from rooms left join reservations  on reservations.r_number = rooms.number and reservations.todate > '4/19/2013' and reservations.fromdate < '4/20/2013' where rooms.r_size = 'roomsize'  and reservations.r_number is null 	0.000960504374820127
16211205	19988	sql server identity related error	select * into dbo.stagingtable from abc where 1=2     go     bulk      insert stagingtable     from 'f:\test.csv'     with     (         fieldterminator = ',',         rowterminator = '\n'     )     go     set identity_insert abc on go     insert into abc (column1,column2,etc)      select * from stagingtable 	0.692962062241965
17047302	36398	mysql select top 10% of users	select user_id, date, total_time from (   select user_id, @rownum:=@rownum+1 as rownum    from table_user , (select @rownum:=0) r   where date = current_date    order by total_time desc ) temp  where rownum < (select count(*) from table_user where date = current_date) / 10 	0.000279555757965101
17294131	2734	display only the last 300 mysql results with a php pagination system	select * from (select * from $tablename where type='6' and country_code='gb' order by auto_incerment_id desc limit 300) as a order by auto_incerment_id asc limit $start, $limit 	0.000177563906035443
17378273	40195	error when trying to update a row with a random value	select id,floor(abs(checksum(newid())) / 2147483647.0 * 3 + 1) as rn into #tmp from name update name set surname=data  from #tmp join sampledata sd on sd.rownumber=#tmp.rn where #tmp.id=name.id select * from name 	0.0585080547080061
17842926	3323	mysql counts based on timestamps?	select count(q.id) from `profile_questions` q  left join profile_answers a on q.id = a.question_id                              and q.user_id = a.answered_by where q.user_id = 5 and a.answered_by is null 	0.00035589494903875
17899066	10342	get rank within table for any number	select count(*)+1 rank from bids where bid_amount > 15 	0.000792223113860728
18638460	32763	mysql query ordering in join tables	select doc.code,doc.dataaccept,doctypes.name,org.name from doc left outer join doctypes join org on doc.type=doctypes.code and doc.org=org.code; where doc.code < 1000 ; order by 1 	0.572800468974092
18869232	6125	how to create in view new row after each next row	select  ...    case when x = 1 then col else your calculation end from table cross join (select 1 as x union all select 2 as x) dt 	0
19428559	21712	select month day year as date in mysql?	select * from mytable where column_month = date_format(current_date, '%c'); 	0
19478482	18756	mysql how to get two results with one query from different tables	select books.book_title, authors.author_name, comments.comment from books inner join books_authors on books.book_id=books_authors.book_id inner join authors on books_authors.author_id=authors.author_id left join comments_users on comments_users.book_id = books.book_id inner join comments on comments_users.comment_id = comments.comment_id inner join users on comments_users.user_id = users.user_id where books.book_id=7 	0
19810799	27943	mysql: display duplicates matching two columns	select id, shipping_date from t group by id, shipping_date having count(*) > 1; 	0
19981150	7692	select some items and if there's not enough of them, add some other items, then sort	select * from (     select * from `items` where important = 1 or type = 'news'      order by `important` desc, `date` desc limit 3 ) x order by `date` desc 	0
19992155	6096	sql one to many join - do not return rows from the 'one' table if any row in the 'many' table equals x	select * from order_items o where item_number not in (     select item_number     from processes     where process_number in (1, 2, 3)     ) 	0
20045045	39944	oracle get numbers with range	select    distinct start_serial+level-1 serial from    yourtable connect by level-1<=end_serial-start_serial order by 1; 	0.0018370137661306
21136741	17724	how to group by a column and show as one row	select subid,         listagg(status, '/') within group (order by null) as status from the_table group by subid; 	7.58778334231397e-05
21505025	5706	add one year, to a year in the where clause	select * from event where year(year) >= ? and year(year) <= ?+1 	0.000195398473545037
21526058	40955	convert rows to string in postgresql	select string_agg(name1, ',') as name1s from t1 	0.0173719828612334
22655765	26781	mysql result set concatenation column wise	select * from (select 1,2) t1 join (select 5,6) t2 union  select * from (select 3,4) t1 join (select 7,8) t2 	0.0265881048673128
22854687	38364	finding the 3rd highest salary in mysql without limit	select *    from one one1    where ( 3 ) = ( select count( one2.salary )                    from one one2                    where one2.salary >= one1.salary                  ) 	5.31482519823384e-05
22911324	29003	how to decrease query execution time with distinct?	select distinct on ( topic_category_id ) * from topic t     where post_time >= abstime(now ( ) - 24 * 3600 )     order by topic_category_id, post_time desc limit 10; 	0.660647325268549
23193306	37584	select company_id for duplicated fields in mysql	select a.company_id,b.company_id as duplicate_company_id from company_table a, company_table b where a.id != b.id and a.company_id != b.company_id and (     a.ph_no = b.ph_no     or     a.mobile_no = b.mobile_no     or     a.email = b.email ) 	0.0270819586021155
23361486	13074	calculate the credit amount the employee	select (select sum(money1) from t1 where job_id='8') -         (select sum(money2) from t2 where job_id='8') 	0.00024599012451715
23430421	14770	how to replace characters before a number in sql	select replace(name, substr(name, 1, regexp_instr( name, '[0-9]', 1)-1), 'port ')  from port 	0.0140798747300573
23739209	2654	how to join these tables in sql	select      c.id 'client_id', g.id 'group_id', isnull(cg.client_id) from     (client c      cross join group g)     left join client_group cg on c.id = cg.client_id and g.id = cg.group_id 	0.270983455306471
23757493	18154	how do i convert columns into rows for each status	select name, 'joined' as [action], join_dt as action_date   from sometable union all   select name, 'started' start_dttm   from sometable union all   select name, 'ended', end_dt   from sometable 	0
23812509	28990	get peer column values from same table using codeigniter and mysql	select  t2.cat_id , t2.subcat_id, t2.name from test t1 join test t2 on t1.cat_id = t2.cat_id where t1.subcat_id = 42 and t2.subcat_id <> 42 	0
23921900	37747	sql query for excluding a key value matching record for a specific condition	select pkid, detailid, type from temp where type <> 5 group by pkid, detailid, type union select pkid, detailid, type from temp  where detailid not in ( select detailid from temp where type <> 5 group by pkid, detailid, type ) order by pkid 	0
24058185	35189	excluding from query all rows related with a value in a subquery result	select c.rec_name from composition c group by c.rec_name having sum(ing_name not in (**subquery**)) = 0; 	0
24314308	22055	mysql join of two select result	select *  from (select id, id_cat, modello            from tbarticoli            where id_cat=5) as tba left join (select idmodello,            floor(avg(voto)) as votomedio            from tbcommenti            group by idmodello) as tbc on tba.id = tbc.idmodello 	0.0247978894457848
24441993	39534	sql -- are there are any rows where a column value is greater than 6?	select * from `at_lesson_assignments`  aa  inner join `at_lesson_assignments_visibility` at on aa.assignment_id = at.assignment_id where unit > 6 	0
24791238	25942	grabbing some part of string using sql server 2012	select replace([column-2],'- x','- zz x') from yourtable 	0.11608990298846
24875194	38591	change column type for multiple tables with same column name	select 'alter table ' + quotename(schema_name(schema_id)) + '.' + quotename(t.name) + ' alter column ' + quotename(c.name) + ' nvarchar(50)' from sys.tables as t inner join sys.columns c on t.object_id = c.object_id where c.name like '%columniwantchanged%' 	0.000206407367639847
25270955	22925	return a result even if select is empty	select p.id, p.name, p.img, p.template_usage, t.name as tpl_name from platforms as p  left join xml_template as t on t.id = p.template_usage 	0.0341953640949674
25314682	10492	join two table with inner join and two external keys	select u1.username, u2.username,social.val  from social   inner join utenti u1 on u1.id_ut=social.id_ut1  inner join utenti u2 on u2.id_ut=social.id_ut2 	0.0915238084701022
25458214	4922	display two date field value formated like "monthname dd-dd, yyyy"	select date_format(startdate,'%m') + date_format(startdate,'%d') + '-' + date_format(enddate,'%d') + ',' + date_format(startdate,'%y')  from yourtable 	0.000489203835832302
25478176	31233	mysql error getting the previous dated record	select * from table where date < (select date from table where ordinal = 5555) order by date desc limit 1; 	0.0160364159867086
25799401	20871	mysql query two tables and max timestamp	select table_conversations.conversation_id, table_conversations.contact_number,        table_conversations.contact_id, max(table_messages.timestamp)  from table_conversations join table_messages on table_conversations.conversation_id = table_messages.conversation_id where table_conversations.status='active'  and table_messages.status='active'  group by contact_number  order by table_messages.timestamp; 	0.00442059638482963
