101

(15 replies, posted in General)

Hi Roberto,


good job.


"frmOverview.TableGrid1.beginUpdate" was lost in the atualiza_overview procedure.
Adding the lost one will speed up the output of data to the table.

Hi Roberto


procedure Form1_OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
  if (Ctrl) and (key=107) then showmessage('You press "+"');   // PLUS on NumPad
  if (Ctrl) and (key=109) then showmessage('You press "-"');   // MINUS on NumPad
end;

103

(2 replies, posted in General)

jrga wrote:
sparrow wrote:

Something like this.

Thankyou

You're welcome.
This version works with TDateTime
There is also a JulianDay version for MVD.

104

(2 replies, posted in General)

Something like this.

105

(12 replies, posted in Script)

Hi all

Encode
Convert hours to seconds(*3600),
convert minutes to seconds(*60).
Add everything you calculated with seconds.(Time1 := H * 3600 + M * 60 + S)
Do this every time and add more. TimeAll := Time1 + Time2 + timeN.
Decode
Now we take the integer from division (TimeAll / 3600). It's an hour.
We divide the remainder of the division (TimeAll mod 3600) by 60. The integer part of the division is minutes.
The remainder of division by 60 (((TimeAll mod 3600) mod 60) is the seconds remaining.

Roberto, use my second example without FLOOR and MOD.


select PRINTF('AMD: %02d %02d %02d',
                         alldays / 365250 ,
                         (alldays % 365250) / 30437 ,
                         ( (alldays % 365250) % 30437)/1000 )
from (select 
    (julianday('now','localtime') - julianday('2022-12-23'))*1000 as alldays  ) as t;

You can't just change '%' instead of MOD,
using '%' instead of MOD has its disadvantages.
Therefore, we operate with integers.
Look at the results, false and true:

select PRINTF('AMD: %02d %02d %02d',
                        cast((alldays / 365.25) as integer),
                        cast(((alldays % 365.25) / 30.4375) as integer),
                        cast((((alldays % 365.25) % 30.4375)) as integer))    
from (select 
    (julianday('now','localtime') - julianday('2022-12-23')) as alldays  ) as t;

AMD: 00 11 04  < -- FALSE

select PRINTF('AMD: %02d %02d %02d',
                         alldays / 365250 ,
                         (alldays % 365250) / 30437 ,
                         ( (alldays % 365250) % 30437)/1000 )
from (select 
    (julianday('now','localtime') - julianday('2022-12-23'))*1000 as alldays  ) as t;


AMD: 00 11 30 < -- TRUE

Hi,
You can try it like this


select PRINTF('AMD: %02d %02d %02d',
                        floor( alldays / 365.25 ),
                        floor( mod(alldays, 365.25) / 30.4375 ),
                        floor( mod( mod(alldays, 365.25), 30.4375) ) )
from (select 
    (julianday('now','localtime') - julianday('2022-10-13')) as alldays  ) as t;    

P.S.
Sorry, I didn't check right away.
For a version of SQLite in a program where some functions are not supported, the query is:

select PRINTF('AMD: %02d %02d %02d',
                         alldays / 365250 ,
                         (alldays % 365250) / 30437 ,
                         ( (alldays % 365250) % 30437)/1000 )
from (select 
    (julianday('now','localtime') - julianday('2022-09-03'))*1000 as alldays  ) as t;

As Derek and Konstantin wrote, the component does not have a name.
And the dynamically CREATED component has index 21.
Therefore frmdbCoreUserForm.components[21] ... . This is how you can reference it.

109

(5 replies, posted in SQL queries)

I suggest reading the manual first.

http://myvisualdatabase.com/help_ru/scr … egrid.html

It looks like the frmdbCoreUserForm combobox is a dynamic component and I don't get how to filter it.


I wrote it that way.

The combo is created on the form when the form starts.

And when this form is ready for display (or has already been created), the combo becomes available for working with it))).
In other cases, there is a component error with this index.

Hi all.


The combo is created on the form when the form starts.
You can refer to it as components[21]

The FastReport script is no different.
You need to read the documentation and you will get an idea of how FastReport events work and how the output is generated on the screen.
Here is the link: https://www.fast-report.com/public_down … ual-en.pdf
FastReport's capabilities, which are described in the manual, are slightly larger. But you will get an idea of how it all works, including in the script.

Something like this.

If you look closely, you will see that the LAST result - Tery - is not displayed.
And if you look at your code, you will see that the previous driver is displayed when the driver is changed DriverName <> currentDriver. But the condition does not work for the last driver.

Sorry, I looked at the wrong report. What exactly do you want to complete in the script?

Implementing such a solution through the FastReport script will require significant effort and programming knowledge from you.

Once again, Derek's solution is optimal and requires a little modification to achieve the result you need.
Ok, I'll do it for you.
Here is Derek's modified solution in two versions.

Derek has provided you with a working solution.
If you edit the calculated field a little and change the Report a little you will get what you call GOOD.
Apply everything you described in the SQL query.
And in the report, remove the grouping.


And you will succeed

118

(8 replies, posted in Russian)

Ваш запрос выглядит мягко говоря - никак


Найдите сначала подзапросом запись которая относится к МАХ(Дата)
А уже к ней присоединяйте что хотите.


И читайте, читайте, читайте.

From your example and message it is not clear what should be calculated and what should be grouped and in which report.
Be specific about your question.
What do you want to get as an output and from what data.

120

(6 replies, posted in General)

var
    SaveDialog: TSaveDialog;
begin
    SaveDialog := TSaveDialog.Create(Form1);
    SaveDialog.Filter := 'CSV file|*.csv';
    saveDialog.DefaultExt := 'csv';

    if SaveDialog.Execute then
    begin
      ShowMessage('Filename ---> '+saveDialog.FileName);      // show path and filename
    end;
    saveDialog.Free;
end;
netros wrote:

Я за 2 недели чего только не прочитал, не перепробовал...

На мой взгляд дело не в очень корректной работе оператора GROUP BY в SQLite/

Просто не первый раз сталкиваюсь с тем, что оператор должен бы сработать одним образом (ну так пишут в книжках), а на выходе имеем немного не то.


Ну хватит... не смешите народ.
Кстати Microsoft, GOOGLE и другие гиганты не жалуются на работу GROUP BY в SQLite. Может не знают про проблемы.


при работе с аггрегатными функциями существуют определенные правила для столбцов в SELECT и GROUP BY.

Улыбнуло
Вокруг столько литературы, сайтов, примеров ...


Кстати вы привели пример CROSS JOIN даже не подозревая об этом.

Спасибо.
А как на счет INNER ?


Ой догадался они без иерархии , они равнозначны. Правильно ?

netros wrote:

...таблицы X и Y находятся СПРАВА, поэтому LEFT JOIN не проходит.

У таблицы Z слева ещё есть справочники, ...


Не совсем понятно о чем вы говорите.
Основную таблицу выборки вы выбираете сами так же как и соединение с другими таблицами,
исходя из того результата который вы хотите получить.

125

(8 replies, posted in Russian)

выполните в SQL

select 12345-12
и
select '12345-12'