~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/having.test

  • Committer: Andrew Hutchings
  • Date: 2010-09-08 19:03:09 UTC
  • mfrom: (1750 staging)
  • mto: (1750.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1751.
  • Revision ID: andrew@linuxjedi.co.uk-20100908190309-mya1nu7xvo1fpvk8
Merge trunk into branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
select count(*) as count_col1 from t1 group by col1 having col1 = 10;
208
208
select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
209
209
select count(*) from t1 group by col2 having col2 = 'hello';
210
 
--error 1054
 
210
--error ER_BAD_FIELD_ERROR
211
211
select count(*) from t1 group by col2 having col1 = 10;
212
212
select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10;
213
213
select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10;
221
221
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10;
222
222
select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello';
223
223
select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello';
224
 
--error 1064
 
224
--error ER_PARSE_ERROR
225
225
select sum(col1) as co12 from t1 group by col2 having col2 10; 
226
226
select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10; 
227
 
--error 1054
 
227
--error ER_BAD_FIELD_ERROR
228
228
select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10;
229
229
 
230
230
 
273
273
 
274
274
# nested queries with HAVING, inner having column resolved in outer FROM clause
275
275
# the outer having column is not referenced in GROUP BY which results in an error
276
 
--error 1054
 
276
--error ER_BAD_FIELD_ERROR
277
277
select t1.col1 from t1
278
278
where t1.col2 in 
279
279
      (select t2.col2 from t2 
302
302
# correlated subqueries - inner having column 't1.col2' resolves to
303
303
# the outer FROM clause, which cannot be used because the outer query
304
304
# is grouped
305
 
--error 1054
 
305
--error ER_BAD_FIELD_ERROR
306
306
select sum(col1) from t1
307
307
group by col_t1
308
308
having col_t1 in (select sum(t2.col1) from t2
318
318
#
319
319
# queries with joins and ambiguous column names
320
320
#
321
 
--error 1052
 
321
--error ER_NON_UNIQ_ERROR
322
322
select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1
323
323
group by t1.col1, t2.col1 having col1 = 2;
324
324
 
325
 
--error 1052
 
325
--error ER_NON_UNIQ_ERROR
326
326
select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1
327
327
group by t1.col1, t2.col1 having col1 = 2;
328
328