Добрый вечер, дамы и господа))
Спросить хотелось бы, чем отличается:
SQL |
$result = mysql_query("SELECT * FROM................."); |
SQL |
$query = "SELECT * FROM............"; $result = mysql_query($query); |
SQL |
select total_info.ne, total_info.tkg, total_info.total_days, bh_block_rate_avg, bh_block_rate_max, bh_block_rate_c , bh_all_busy_rate_avg, bh_all_busy_rate_max, bh_all_busy_rate_c , bh_asr_inc_avg, bh_asr_inc_max, bh_asr_inc_c , bh_asr_og_avg, bh_asr_og_max, bh_asr_og_c , bh_mht_inc_avg, bh_mht_inc_max, bh_mht_inc_c , bh_mht_og_avg, bh_mht_og_max, bh_mht_og_c , day_asr_avg, day_asr_max, day_asr_c , day_ner_avg, day_ner_max, day_ner_c , bh_asr_avg, bh_asr_max, bh_asr_c , bh_ner_avg, bh_ner_max, bh_ner_c from (select trim(ne) as ne, trim(tkg) as tkg, count(ne) as total_days from msc_tkg where bh_servicing > 0 and now() - report_day <= interval '30 day' group by ne, tkg) total_info left join ( ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_block_rate) as bh_block_rate_avg, min(bh_block_rate) as bh_block_rate_min, max(bh_block_rate) as bh_block_rate_max, count(ne) as bh_block_rate_c from msc_tkg where bh_servicing >0 and bh_block_rate > 0.1 and bh_block_rate < 110 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_block_rate_info full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_all_busy_rate) as bh_all_busy_rate_avg, min(bh_all_busy_rate) as bh_all_busy_rate_min, max(bh_all_busy_rate) as bh_all_busy_rate_max, count(ne) as bh_all_busy_rate_c from msc_tkg where bh_servicing >0 and bh_all_busy_rate > 0.1 and bh_all_busy_rate < 110 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_all_busy_rate_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_asr_inc) as bh_asr_inc_avg, min(bh_asr_inc) as bh_asr_inc_min, max(bh_asr_inc) as bh_asr_inc_max, count(ne) as bh_asr_inc_c from msc_tkg where bh_servicing >0 and bh_asr_inc > 0 and bh_asr_inc < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_asr_inc_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_asr_og) as bh_asr_og_avg, min(bh_asr_og) as bh_asr_og_min, max(bh_asr_og) as bh_asr_og_max, count(ne) as bh_asr_og_c from msc_tkg where bh_servicing >0 and bh_asr_og > 0 and bh_asr_og < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_asr_og_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_mht_inc) as bh_mht_inc_avg, min(bh_mht_inc) as bh_mht_inc_min, max(bh_mht_inc) as bh_mht_inc_max, count(ne) as bh_mht_inc_c from msc_tkg where bh_servicing >0 and bh_mht_inc > 0 and bh_mht_inc < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_mht_inc_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_mht_og) as bh_mht_og_avg, min(bh_mht_og) as bh_mht_og_min, max(bh_mht_og) as bh_mht_og_max, count(ne) as bh_mht_og_c from msc_tkg where bh_servicing >0 and bh_mht_og > 0 and bh_mht_og < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_mht_og_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(day_asr) as day_asr_avg, min(day_asr) as day_asr_min, max(day_asr) as day_asr_max, count(ne) as day_asr_c from msc_tkg where bh_servicing >0 and day_asr > 0 and day_asr < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) day_asr_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(day_ner) as day_ner_avg, min(day_ner) as day_ner_min, max(day_ner) as day_ner_max, count(ne) as day_ner_c from msc_tkg where bh_servicing >0 and day_ner > 0 and day_ner < 80 and now() - report_day <= interval '30 day' group by ne, tkg ) day_ner_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_asr) as bh_asr_avg, min(bh_asr) as bh_asr_min, max(bh_asr) as bh_asr_max, count(ne) as bh_asr_c from msc_tkg where bh_servicing >0 and bh_asr > 0 and bh_asr < 40 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_asr_info using( ne, tkg) full join ( select trim(ne) as ne, trim(tkg) as tkg, avg(bh_ner) as bh_ner_avg, min(bh_ner) as bh_ner_min, max(bh_ner) as bh_ner_max, count(ne) as bh_ner_c from msc_tkg where bh_servicing >0 and bh_ner > 0 and bh_ner < 80 and now() - report_day <= interval '30 day' group by ne, tkg ) bh_ner_info using( ne, tkg) ) using (ne, tkg) where bh_block_rate_c/total_days >= 0.5 or bh_all_busy_rate_c/total_days >= 0.5 or bh_asr_inc_c/total_days >= 0.5 or bh_asr_og_c/total_days >= 0.5 or bh_mht_inc_c/total_days >= 0.5 or bh_mht_og_c/total_days >= 0.5 or day_asr_c/total_days >= 0.5 or day_ner_c/total_days >= 0.5 or bh_asr_c/total_days >= 0.5 or bh_ner_c/total_days >= 0.5 order by ne, tkg |
Цитата (Gabriel @ 3.11.2009 - 18:55) |
это что за монстр такой |
Цитата (uMnepaTop @ 3.11.2009 - 20:31) |
афигеть.... вот это запросище... |
Цитата (glock18 @ 3.11.2009 - 18:26) |
простой ведь запросик то |
Цитата (Gabriel @ 3.11.2009 - 18:55) |
сновa постгрю рекламируем? |