[firebird-support] Order by

2015-10-06 Thread Germán Balbi bal...@yahoo.com [firebird-support]
Hello everyone There is the possibility of ordering the result of a SELECT in an order  specified by the user.For examplehaving a field NAMEin the clause ORDER BY  'PAUL, JOHN, PETER, MARIA' Of course, that should be all the options set Thank you. Hola a todos Existe la posibilidad de ordenar el r

[firebird-support] order by

2014-04-07 Thread checkmail
Hello, I've a litte question. Now I can order by the column number, order by 1. Can I set this information with a variable? Dim k as integer = 1; Order by :k? Thanks

Re: [firebird-support] Order by

2015-10-06 Thread liviusliv...@poczta.onet.pl [firebird-support]
Hi, ORDER BY CASE USER_NAME WHEN ‘PAUL’ THEN 1 WHEN ‘JOHN’ THEN 2 .. END regards, Karol Bieniaszewski From: mailto:firebird-support@yahoogroups.com Sent: Tuesday, October 06, 2015 5:20 PM To: Firebird Support Subject: [firebird-support] Order by Hello everyone There is the possibility

Re: [firebird-support] Order by

2015-10-06 Thread Germán Balbi bal...@yahoo.com [firebird-support]
rd-support@yahoogroups.com Sent: Tuesday, October 06, 2015 5:20 PMTo: Firebird Support Subject: [firebird-support] Order by   Hello everyone There is the possibility of  ordering the result of a SELECT in an order specified by the user.For  examplehaving a field NAMEin the clause ORDER BY 'PAUL, JOHN, P

Re: [firebird-support] Order by

2015-10-06 Thread 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
ds, > Karol Bieniaszewski > > *From:* mailto:firebird-support@yahoogroups.com > > *Sent:* Tuesday, October 06, 2015 5:20 PM > *To:* Firebird Support > *Subject:* [firebird-support] Order by > > > Hello everyone > > There is the possibility of ordering the result of a SELE

Re: [firebird-support] Order by

2015-10-07 Thread Germán Balbi bal...@yahoo.com [firebird-support]
s.com Sent: Tuesday, October 06, 2015 5:20 PMTo: Firebird Support Subject: [firebird-support] Order by   Hello everyone There is the possibility of  ordering the result of a SELECT in an order specified by the user.For  examplehaving a field NAMEin the clause ORDER BY 'PAUL, JOHN, PETER, MARI

Re: [firebird-support] Order by

2015-10-07 Thread 'Walter R. Ojeda Valiente' sistemas2000profesio...@gmail.com [firebird-support]
ple. Thank Karol > > > > > El Martes, 6 de octubre, 2015 16:32:08, "liviusliv...@poczta.onet.pl > [firebird-support]" escribió: > > > > Hi, > > ORDER BY CASE USER_NAME WHEN ‘PAUL’ THEN 1 WHEN ‘JOHN’ THEN 2 .. END > > regards, > Karol Bieniasze

Re: [firebird-support] order by

2014-04-07 Thread Andrea Raimondi
I don't think so. And anyway, you should never be using an order by number - unless there is really no way around it, in my opinion. A On Mon, Apr 7, 2014 at 11:47 AM, checkmail wrote: > > > Hello, > > > > I've a litte question. Now I can order by the column number, order by 1. > Can I set th

Re: [firebird-support] order by

2014-04-07 Thread Tim Ward
On 07/04/2014 12:40, Andrea Raimondi wrote: And anyway, you should never be using an order by number - unless there is really no way around it, in my opinion. When people make statements like that it would be really helpful if they were to say *why* they are of this opinion, otherwise the read

Re: [firebird-support] order by

2014-04-07 Thread Andrea Raimondi
I am of this opinion because SQL scripts change and what is today column number 2 may become column number 14 two days later. This, in turn, leads to potential problems because you think it's ordering by something whereas instead it's ordering by something else. A On Mon, Apr 7, 2014 at 2:58 PM,

Re: [firebird-support] order by

2014-04-07 Thread Tim Ward
Thanks. Knowing this reasoning, one can then use one's judgement in comparing this reason against a desire to avoid repeating a long complex expression which could also lead to a maintenance risk. On 07/04/2014 15:02, Andrea Raimondi wrote: I am of this opinion because SQL scripts change and wh

Re: [firebird-support] order by

2014-04-07 Thread Andrea Raimondi
To avoid those cases, I will usually wrap the long and complex expression in an outer select giving it an intuitive column name. It does not work in *all* cases, but it does work in most. A On Mon, Apr 7, 2014 at 3:05 PM, Tim Ward wrote: > > > Thanks. Knowing this reasoning, one can then use o

Re: [firebird-support] order by

2014-04-07 Thread Ann Harrison
On Mon, Apr 7, 2014 at 6:47 AM, checkmail wrote: > > > I've a litte question. Now I can order by the column number, order by 1. > Can I set this information with a variable? > > Dim k as integer = 1; > > Order by :k? > > > You can do the equivalent with an EXECUTE STATEMENT.With the exception

AW: [firebird-support] order by

2014-04-07 Thread checkmail
Thanks @ll J Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] Im Auftrag von Ann Harrison Gesendet: Montag, 7. April 2014 17:30 An: firebird-support@yahoogroups.com Betreff: Re: [firebird-support] order by On Mon, Apr 7, 2014 at 6:47 AM, checkmail wrote

[firebird-support] ORDER BY too slow

2019-03-20 Thread firebirdbest...@yahoo.com [firebird-support]
I'm building a major product using Lazarus 1.8.4, FPC 3.0.4, IBX 2.3.3 and Firebird RDBMS 3x. I have a query that runs in the range of 1 to 3 milliseconds without the ORDER BY clause. But once I add the ORDER BY clause, the query takes > 1.5 seconds. Be advised that there is an index on the

[firebird-support] order by with grouping?

2013-01-24 Thread bwc3068
hi-- always a great place to get help!! here's what i have data wise: Tag ID Date ABC 11 2012 DEF 11 2011 GHJ 11 2010 HHH 22 2012 ZZZ 22 2011 AAA 22 2010 AAK 33 2012 AAD 44 2012 YYY 44 2010 IF i select * order by t

Re: [firebird-support] ORDER BY too slow

2019-03-21 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
Hiyes, slowdown is because of sort as engine must sort the table first and then retrieve 10 records.But you can try to speed this up by:SELECT  FIRST 10 SKIP 0  msg.OBJ_GUID AS "MSG_GUID", msg.PRTY, msg.TTL,  pst.OBJ_GUID AS "PST_GUID", pst.MSTB_DTSFROM  (Select * from MSGS m order by m.PRTY) ms

[firebird-support] order by takes too long

2020-03-02 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hello, I guess this is another beginners question: I have a table with 300`000 entries. Each row has a separate field TIMESTAMP with its creation data. Now, I query the latest 100 hundred using: select first(100) X, Y, TIMESTAMP from MY_TABLE order by TIMESTAMP DESC -- order by takes all the t

RE: [firebird-support] order by with grouping?

2013-01-24 Thread Leyne, Sean
Kelly, > always a great place to get help!! > > here's what i have data wise: > > Tag ID Date > > ABC 11 2012 > DEF 11 2011 > GHJ 11 2010 > HHH 22 2012 > ZZZ 22 2011 > AAA 22 2010 > AAK 33 2012 > AAD 44 2012 > YYY 44

[firebird-support] order by 1, 2 - fb 32990

2018-04-12 Thread acgomes2...@yahoo.com.br [firebird-support]
hi: select A.Codigo 'DINHEIRO' FORMA_PAGTO FROM NF A where A.dataEmissao between '01.01.2018' and '31.01.2018' and A.Modelo = '55' order by 1, 2 using, "order by 2", return a error but, if i use: cast('DINHEIRO' as varchar(10)) FORMA_PAGTO does not ocorrur.

RE: [firebird-support] order by takes too long

2020-03-02 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
HiWithout analysis i can only advice to create descending index.Create descending index ixd_mytable__timestamp on mytable(timestamp)Regards,Karol Bieniaszewski null

Re: [firebird-support] order by takes too long

2020-03-03 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hello, it seems the problem is related to the VIEW. This is what I also figured out so far. Now I read: "If you see a *NATURAL *plan going against a big table, you've found the problem. If you have where clause or JOIN to that table, make sure you have index defined on related fields. If you do h

AW: [firebird-support] order by takes too long

2020-03-03 Thread 'Mathias Pannier (unitel)' pann...@ubsysteme.de [firebird-support]
: [firebird-support] order by takes too long Hello, it seems the problem is related to the VIEW. This is what I also figured out so far.. Now I read: "If you see a NATURAL plan going against a big table, you've found the problem. If you have where clause or JOIN to that table, make sur

Re: [firebird-support] order by takes too long

2020-03-03 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
@yahoogroups.com [mailto: > firebird-support@yahoogroups.com] > *Gesendet:* Dienstag, 3. März 2020 12:41 > *An:* firebird-support@yahoogroups.com > *Betreff:* Re: [firebird-support] order by takes too long > > > > > > Hello, > > > > it seems the problem is related t

Re: [firebird-support] order by takes too long

2020-03-03 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
03.03.2020 13:23, Matthias Winkler spmm...@gmail.com [firebird-support] wrote: > The question is when and how decides the generator > of the "plan" that it connot use the indexes http://www.ibase.ru/dataaccesspaths/ -- WBR, SD. --

AW: [firebird-support] order by takes too long

2020-03-03 Thread 'Mathias Pannier (unitel)' pann...@ubsysteme.de [firebird-support]
Betreff: Re: [firebird-support] order by takes too long Hello, I already re-calculated the indexes. But as far as I understood is that as soon as the natural keyword is present the indexes are not used at all. The question is when and how decides the generator of the "plan" that it conn

[firebird-support] order by using parameter of stored procedure

2012-03-18 Thread Newbie
How to best implement ORDER BY of a query when the field by which to order, is given as stored procedure input parameter? for example a typical product list where could be ordered by Name, Price etc fields depending on what user clicks. I tried to include it into query: for select f1, f2 from t

[firebird-support] Order by :variable in a Stored Procedure

2015-11-03 Thread Gugui gugui_sarubi_mac...@yahoo.com.br [firebird-support]
Hi all, is it possible to pass a variable into a Order by ? I did it and the StoredProcedure was created without errors but the variable passed into an 'order by' was ignored and firebird assumed the primary key order instead any tip ? thanks --

Re: [firebird-support] order by 1, 2 - fb 32990

2018-04-12 Thread Helen Borrie hele...@iinet.net.au [firebird-support]
acgomes2...@yahoo.com.br wrote: > select > A.Codigo > 'DINHEIRO' FORMA_PAGTO > FROM NF A > where A.dataEmissao between '01.01.2018' and '31.01.2018' > and A.Modelo = '55' This should work fine if you place a comma after A.Codigo. It does not make any sense to ORDER BY 2 (nor ORDER BY 1,2)

Re: [firebird-support] order by 1, 2 - fb 32990

2018-04-13 Thread acgomes2...@yahoo.com.br [firebird-support]
hi helen... the comma is the less problem... A correct sql: select N.DTEMISSAONOTA as DATA, 'DINHEIRO' as MEIO_PAGAMENTO1, cast('DINHEIRO' as char(10)) as MEIO_PAGAMENTO2, '00' as MEIO_PAGAMENTO, N.VLRTOTALNOTA as VALOR, 0 as AUTENT_01, 0 a

RE: AW: [firebird-support] order by takes too long

2020-03-03 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
This advice should be oppositeYou should not have order by in the view.Only exception is when you always do only simple select * from myviewRegards,Karol Bieniaszewski null

Re: AW: [firebird-support] order by takes too long

2020-03-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hello, I tried the sorting inside and outside a minimal view and it actually worked in both cases without non-indexed reads, meaning FAST. By stripping down my complex view it turned out that a "inner join" with another table inside the view killed my performance. I will now try to evaluate if I

Re: AW: [firebird-support] order by takes too long

2020-03-04 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
HiYou can always change inner join to pseudo inner join without affecting resultset. But better you should find the reason of this slowdown as it looks like index without recent stats or wrong indexing in join. But it also can be something else.Regards,Karol Bieniaszewski null

Re: AW: [firebird-support] order by takes too long

2020-03-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hi Karol, Thanks for your reply. Can you outline how I would do a "inner join to pseudo inner join without affecting resultset". Matthias On Wed, Mar 4, 2020 at 10:12 AM liviuslivius liviusliv...@poczta.onet.pl [firebird-support] wrote: > > > Hi > > You can always change inner join to ps

Re: AW: [firebird-support] order by takes too long

2020-03-04 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
Pseudo inner join is left join with where clause about not null from left joined tableSelectFromTable1 t1 left join Table2 t2 on t1.id=t2.id_t1Wheret2.id is not nullRegards,Karol Bieniaszewski null

Re: AW: [firebird-support] order by takes too long

2020-03-04 Thread Matthias Winkler spmm...@gmail.com [firebird-support]
Hi Karol, perfect! I usually say that I hate DBs but the more I gain deep insights I start to like it. Thank you for your help! Matthias liviuslivius liviusliv...@poczta.onet.pl [firebird-support] < firebird-support@yahoogroups.com> schrieb am Mi., 4. März 2020, 19:38: > > > Pseudo inner join

[firebird-support] Order By Not Working Using "WITH" Clause

2015-07-03 Thread Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]
Hi All, I have below SQL, which is concatenating the ShortCode column data, but without ordering as per the ORDER_NUMBER column in ABC table in "WITH" clause. Please help. With TBL_SHORT_CODE (SHORT_CODE, FK_KEY) As (SELECT Distinct(XYZ.SHORT_CODE) As SHORT_CODE, ABC.FK_KEY From ABC Join XYZ On

Re: [firebird-support] order by using parameter of stored procedure

2012-03-18 Thread Helen Borrie
At 09:26 AM 19/03/2012, Newbie wrote: >How to best implement ORDER BY of a query when the field by which to >order, is given as stored procedure input parameter? It is not possible to that directly, as ORDER BY is a structural element that is pre-compiled. >for example a typical product list wh

Re: [firebird-support] order by using parameter of stored procedure

2012-03-19 Thread Mark Rotteveel
On Sun, 18 Mar 2012 22:26:11 +0200, Newbie wrote: > How to best implement ORDER BY of a query when the field by which to > order, is given as stored procedure input parameter? > for example a typical product list where could be ordered by Name, Price > etc fields depending on what user clicks. >

Re: [firebird-support] order by using parameter of stored procedure

2012-03-20 Thread Tomasz Tyrakowski
> How to best implement ORDER BY of a query when the field by which to > order, is given as stored procedure input parameter? If the data set returned by the procedure is not very large, return all relevant fields from the procedure and use order by in the query selecting from the procedure (it

Re: [firebird-support] order by using parameter of stored procedure

2012-03-20 Thread Ann Harrison
On Tue, Mar 20, 2012 at 12:48 PM, Tomasz Tyrakowski < t.tyrakow...@sol-system.pl> wrote: > > How to best implement ORDER BY of a query when the field by which to > > order, is given as stored procedure input parameter? > > If the data set returned by the procedure is not very large, return all >

Re: [firebird-support] Order by :variable in a Stored Procedure

2015-11-03 Thread 'Mark Rotteveel' m...@lawinegevaar.nl [firebird-support]
executing it with execute statement, with risk for SQL injection. Mark - Reply message - Van: "Gugui gugui_sarubi_mac...@yahoo.com.br [firebird-support]" Aan: Onderwerp: [firebird-support] Order by :variable in a Stored Procedure Datum: di, nov. 3, 2015 19:58 Hi all, is it possible

Re: [firebird-support] Order By Not Working Using "WITH" Clause

2015-07-03 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On Fri, 3 Jul 2015 12:15:31 + (UTC), "Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]" wrote: > Hi All, > I have below SQL, which is concatenating the ShortCode column data, but > without ordering as per the ORDER_NUMBER column in ABC table in "WITH" > clause. > Please help. > > With

Re: [firebird-support] Order By Not Working Using "WITH" Clause

2015-07-03 Thread Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]
Even if I don't use Distinct, i don't get expected result. On Friday, 3 July 2015 7:17 PM, "Mark Rotteveel m...@lawinegevaar.nl [firebird-support]" wrote:   On Fri, 3 Jul 2015 12:15:31 + (UTC), "Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]" wrote: > Hi All, > I ha

Re: [firebird-support] Order By Not Working Using "WITH" Clause

2015-07-03 Thread 'Mark Rotteveel' m...@lawinegevaar.nl [firebird-support]
get a deterministic order. Mark - Reply message - Van: "Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]" Aan: "firebird-support@yahoogroups.com" Onderwerp: [firebird-support] Order By Not Working Using "WITH" Clause Datum: vr, jul. 3, 2015 17:00 Even i

RE: [firebird-support] Order By Not Working Using "WITH" Clause

2015-07-03 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
>Hi All, > >I have below SQL, which is concatenating the ShortCode column data, but >without ordering as per the ORDER_NUMBER column in ABC table in "WITH" clause. > >Please help. > >With TBL_SHORT_CODE (SHORT_CODE, FK_KEY) As  >( >SELECT Distinct(XYZ.SHORT_CODE) As SHORT_CODE, ABC.FK_KEY  >From A

Re: [firebird-support] Order By Not Working Using "WITH" Clause

2015-07-06 Thread Vishal Tiwari vishuals...@yahoo.co.in [firebird-support]
Hi SET, You have done it this time too Your SQL worked with a small amount of change in below statement     DECLARE VARIABLE FK_BOM2 VARCHAR(2000); Because FK_BOM2 is of GUID type. You are awesome as usual. I would like to say Thank You from bottom of HEART  Thanks Once Again SET... You A