ODP: Re: [firebird-support] How to add previous column value to current value?
I can't. sql is generated dynamicly Wysłano ze smartfonu Sony Xperia™ Użytkownik Michal Kurczabinski michk...@gmail.com [firebird-support] napisał > > >Try this: > >select t.name, t.data, coalesce(t.data -(select data from t1 d where d.id = >t.id -1),0) from t1 t > >-- >regards, >Michał Kurczabiński > > > > >
Re: [firebird-support] How to add previous column value to current value?
Try this: select t.name, t.data, coalesce(t.data -(select data from t1 d where d.id = t.id -1),0) from t1 t -- regards, Michał Kurczabiński
Re: [firebird-support] How to add previous column value to current value?
>I need something like this > >Name Date Days betwen Previous date >-- >Name1 date10 >Name2 date2date2-date1 >Name3 date3date3-date2 I agree with Thomas in that EXECUTE BLOCK is probably the best solution, but an (inferior) alternative is: SELECT T1.Name, T1.MyDate, coalesce(T1.MyDate - (SELECT MAX(T2.MyDate) FROM MyTable T2 WHERE T1.MyDate > T2.MyDate), 0) FROM MyTable T1 The main reason for me calling it inferior, is that it will be slow for large tables without additional selective WHERE criteria for T2. HTH, Set ++ 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/
RE: [firebird-support] How to add previous column value to current value?
let's assume that I have 2.5.3 Pozdrawiam Piotr Olszewski -Original Message- From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] Sent: Tuesday, March 29, 2016 11:45 AM To: firebird-support@yahoogroups.com Subject: Re: [firebird-support] How to add previous column value to current value? 29.03.2016 11:40, 'Piotr Olszewski' piotr.olszew...@eskrzynka.pl [firebird-support] wrote: > I need to get a date difference (days between) between rows. With Firebird 3.0 you can use window function LAG. -- WBR, SD. ++ 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
Re: [firebird-support] How to add previous column value to current value?
29.03.2016 11:40, 'Piotr Olszewski' piotr.olszew...@eskrzynka.pl [firebird-support] wrote: > I need to get a date difference (days between) between rows. With Firebird 3.0 you can use window function LAG. -- WBR, SD. ++ 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/
[firebird-support] How to add previous column value to current value?
Hi I need to get a date difference (days between) between rows. Let say i have: Name Date --- Name1 date1 Name2 date2 Name3 date3 Order by date I need something like this Name Date Days betwen Previous date -- Name1 date10 Name2 date2date2-date1 Name3 date3date3-date2 sql is generated dynamically and it's quite complicated so i can't use procedure to do this. Regards Piotr Olszewski