Hi!

I tried this approach before, but it violates my "only run GET_DATA
once" requirement :-(

Josef

On 21.10.2014 21:15, Svein Erling Tysvær
svein.erling.tysv...@kreftregisteret.no [firebird-support] wrote:
>  
> 
> What about
> 
> FOR WITH TMP(MyDateTime, MySum) as
> (SELECT MIN(dateandtime), SUM(Value)
> FROM gen_data(...))
> SELECT g.id, g.name, g.dateandtime, g.value, t.MyDateTime, tMySum
> FROM gen_data(...) g
> CROSS JOIN tmp t
> 
> Of course, you may want a different join to CROSS JOIN.
> 
> HTH,
> Set
> ________________________________________
> Fra: firebird-support@yahoogroups.com [firebird-support@yahoogroups.com]
> Sendt: 21. oktober 2014 09:39
> Til: Firebird Support
> Emne: [firebird-support] PSQL: Getting both aggregation and individual rows
> 
> Hi!
> 
> Is there a simple way to get an aggregation of some query as well as the
> individual rows from within a PSQL? I.e., I have a stored procedure
> GEN_DATA which produces individual rows (ID, Name, DateAndTime, Value).
> I am processing the output of GEN_DATA in another stored procedure
> PROCESS_DATA:
> 
> FOR SELECT id, name, dateandtime, value
> FROM gen_data(...)
> INTO ...
> DO ...
> 
> Within this loop, I need the individual records, but I also need some
> aggregations on them, i.e. MIN(dateandtime) or SUM(value). If I could
> run GEN_DATA twice, then it would be easy (in the first run I would
> calculate the aggregations, in the second run the individual values),
> but I can't. If I could perform the processing in my application (rather
> than the stored procedure), it would be easy, too (I would simply
> traverse the result dataset of GEN_DATA twice), but again I can't do
> that. Would Common Table Expressions or perhaps Derived Tables help me?
> 
> Thanks,
> 
> Josef
> 
> 



------------------------------------

------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    firebird-support-dig...@yahoogroups.com 
    firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

  • ... Josef Kokeš j.ko...@apatykaservis.cz [firebird-support]
    • ... Josef Kokeš j.ko...@apatykaservis.cz [firebird-support]
      • ... 'Edward Mendez' emendez...@nc.rr.com [firebird-support]
        • ... Josef Kokeš j.ko...@apatykaservis.cz [firebird-support]
    • ... Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
      • ... Josef Kokeš j.ko...@apatykaservis.cz [firebird-support]
        • ... Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
          • ... Josef Kokeš j.ko...@apatykaservis.cz [firebird-support]
    • ... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]

Reply via email to