Re: using alias in where clause
Reindl Harald <[email protected]>
| Newsgroups | gmane.comp.db.mysql.general |
|---|---|
| Organization | the lounge interactive design |
| Message-ID | <[email protected]> |
Am 26.01.2016 um 01:16 schrieb Larry Martell: > I know I cannot use an alias in a where clause, but I am trying to > figure out how to achieve what I need. > > If I could have an alias in a where clause my sql would look like this: > > SELECT IFNULL(f_tag_bottom, > IFNULL(f_tag_bottom_major_axis, > IFNULL(f_tag_bottom_minor_axis, > IFNULL(f_tag_ch_x_bottom, > IFNULL(f_tag_ch_y_bottom, NULL))))) as ftag, > STDDEV(ch_x_top) > FROM data_cst > WHERE ftag = 'E-CD7' > GROUP BY wafer_id, lot_id > > But I can't use ftag in the where clause. I can't put it in a having > clause, as that would exclude the already aggregated rows and I want > to filter then before the aggregation. Anyone have any idea how I can > do this? why would you want to do that? it would make the where clause not be able to use proper indexes
signature.asc
(application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlamvY0ACgkQhmBjz394AnmwcQCgmlgONcaUPMo95EQcBrIViY9O qfQAoI7Gq2VVsQBKR1V7SPezLJnx8aCu =tHks -----END PGP SIGNATURE-----