John Coryat Systems

PostgreSQL Statements of Interest



Various SQL constructs:

Join two tables, omit invalids:

	select * from ete1f join ettkf using (idettk) ;

Join two tables, include invalids:

	select * from ete1f left join ettkf using (idettk) ;

Join several tables in a "chain" join:

	select * from ete1f left join ettkf using (idettk) left join etatf using (idetat) left join rfunf using (idrfun) left join rflof using (idrflo) ;

Select invalid entries from one table: (ettkf)

	select idettk from ete1f except select idettk from ete1f join ettkf using (idettk) ;

Select a total from one table and join with another:

	select * from (select count(idettk) as total,idettk from ete1f group by idettk order by idettk) as temp left join ettkf using (idettk);

Select a total from one table and use it to subtotal from another table:

	select count(total),mkxgenrex from (select count(idettk) as total,idettk from ete1f group by idettk order by idettk) as temp left join ettkf using (idettk) group by mkxgenrex order by mkxgenrex ;

Combination of totals and joins with chained joins and where:

	select * from (select count(idettk) as total,idettk,idrfun from ete1f where playdate >= '2003/01/01' and playdate <= '2003/03/01' group by idrfun,idettk order by idrfun,idettk) as temp left join ettkf using (idettk) left join etatf using (idetat) left join rfunf using (idrfun) left join rfomf using (idrfom) left join rflof using (idrflo) order by idettk;



Check out this interesting knowledge quiz: TIZY Multiple Choice Quiz Game

Check out this aircraft identification quiz: TIZY PLANES

Check out my dog's site: CUTEDOG

Copyright © 1996-2005 John Coryat Systems All rights reserved.