pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Question about a select 2+ messages / 2 participants [nested] [flat]
* Question about a select @ 2005-01-22 15:56 Kretschmer Andreas <andreas_kretschmer@despammed.com> 0 siblings, 1 reply; 2+ messages in thread From: Kretschmer Andreas @ 2005-01-22 15:56 UTC (permalink / raw) To: pgsql-sql Hi, I have a table with this columns: machine, date and area. Now i need a view with machine an week, calculated from date, and sum(area), where date between CURRENT_DATE and now+N days. Okay, this is not the problem, it works fine. (the original table and the view is more complex) The problem is, i need also rows for machine and week with no entrys in the table. For this rows the sum(area) shold be NULL ore 0. In other words: for every machine i need M rows, and M must be constant. Regards & Thx, Andreas -- Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau- fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Question about a select @ 2005-01-23 15:37 Harald Fuchs <hf0722x@protecting.net> parent: Kretschmer Andreas <andreas_kretschmer@despammed.com> 0 siblings, 0 replies; 2+ messages in thread From: Harald Fuchs @ 2005-01-23 15:37 UTC (permalink / raw) To: pgsql-sql In article <20050122155611.GA6592@kaufbach.delug.de>, Kretschmer Andreas <andreas_kretschmer@despammed.com> writes: > Hi, > I have a table with this columns: machine, date and area. > Now i need a view with machine an week, calculated from date, and > sum(area), where date between CURRENT_DATE and now+N days. > Okay, this is not the problem, it works fine. > (the original table and the view is more complex) > The problem is, i need also rows for machine and week with no entrys in > the table. For this rows the sum(area) shold be NULL ore 0. > In other words: for every machine i need M rows, and M must be constant. Week values don't automagically spring into existance when there are no corresponding entries in your table. Use a set-returning function for generating the week values you're interested in, and left-join your table to the SRF. ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-01-23 15:37 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2005-01-22 15:56 Question about a select Kretschmer Andreas <andreas_kretschmer@despammed.com> 2005-01-23 15:37 ` Harald Fuchs <hf0722x@protecting.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox