Добрый,

начало понятно а потом нет ).
Но это хорошо. Хорошо, что вы сами понимаете.

Вопрос: а что вам мешает связать все таблицы Dogovor, BDp (Client) если они связаны через Client?
Связать не значит выводить все данные, а только нужные вам.
И фильтровать тогда можно по любым критериям. Человек, специалист, инженер, даты. Опись, протокол, сдал, принял.)

Вы ж все равно формируете SQL запросом в скрипте. JOIN таблицы между собой и вперед.

SELECT BDp.position
FROM Client 
LEFT JOIN Dogovor ON  Dogovor.xxx=Client.xxx
LEFT JOIN BDp ON  BDp.xxx=Client.xxx
WHERE Client='Сеня'
AND Dogovor.date >= '2012-01-01'
...

А вот случай неправильно сформированного запроса в программе наблюдался.
Виной тому послужили JOIN и порядок в котором объединялись таблицы.
Ну хотелось человеку именно так выбрать главную таблицу в запросе. Имеет право.
Программа запрос отработала с неправильным результатом.
А Database Administration tool не принимал такой запрос (неверное объединение).

Такой случай для автоматизации хуже.

Да есть такое.

И лучше иногда не смотреть в логи сформированных программой запросов ).
Но это небольшая плата за автоматизацию и простоту для небольших задач/ проектов. Золотая середина.
В случае большой надобности можно перейти и на "ручной" режим в скрипте.
Но это уже совсем другая история.


Вообщем иногда лучшее враг хорошего.

конечно
strftime() function returns the date formatted according to the format string.
Обратите еще внимание на то, что я дописал в сообщении выше.

eugene1995miroshnikov wrote:

Запрос бывает отбрасывает несколько строк, тем самым не получает Взять первую дату и конечную для определённого наименования. И я не могу сообразить как правильно оформить запрос, думаю сделать ещё подзапрос… или пробовать group by только для наименования делать, а на даты сделать запрос с min max where наименование=наименованию

Было бы неплохо если бы вы приложили проект или пример.
Попробуйте запрос привести к виду

SELECT strftime("%d.%m.%Y -",MIN(Boev.BoevDate)) AS PeriodDate,
strftime("%d.%m.%Y г.;",MAX(Boev.BoevDateEnd)) AS PeriodDateEnd, 
BoevName.BoevName
...

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

806

(9 replies, posted in General)

OK
http://myvisualdatabase.com/forum/viewt … 027#p42027
I wrote above what needs to be done.

807

(9 replies, posted in General)

You have not answered the question of how to count, the difference of which values and what to multiply by.
I think you wanted to do so.
1. Delete the sqlite.db file in the folder project
2. Replace

procedure frmCompteur_Button1_OnClick
...
else
frmCompteur.edTotalRelevé.Value := frmCompteur.edRelevéDépart.Value - frmCompteur.edRelevéArrivé.Value;
...

3. Replace

procedure frmCompteur_Button2_OnClick
...
else
frmCompteur.edTotalPrixEuros.Value := frmCompteur.edTotalRelevé.Value * frmCompteur.edPrixkWh.Value;
...

4. Run

808

(9 replies, posted in General)

Amazing calculations in the script for
frmCompteur_Button1_OnClick
and
frmCompteur_Button2_OnClick.
Are you sure everything is correct there?
What do you want to calculate?

809

(11 replies, posted in Reports)

Good decision ehwagner


Small correction for more than 10 records in one Order.
Continued printing on the next page. Again 10 per sheet, etc.
Order # 10 contains more than 20 test records.

810

(11 replies, posted in Reports)

Hi Derek.

As I understand it, the Table in FastReport should be of fixed length. Let's say 10 lines and no matter how many of them are filled. All others are empty.
Therefore, the solution above is proposed without unnecessary entries with NULL in the data table.
FastReport hasn't looked at it yet.

joshuA wrote:

... a form that matches the format of a company standard form with a set amount of lines....

I also had a question and if > 10 or another amount. Probably the company has its own answer.

DriveSoft link to FastReport 4 version documentation.

811

(11 replies, posted in Reports)

Hi Derek,Joshua.

Quick solution to not insert null row data after records.
SQLite does not support variables and we will not create temporary tables in memory.
Create a separate table. For example "tenlines". With one column "num". Fill it in with numbers from 1 to 10 or any number 1 only all 10 lines.
You can enter data into the table in the script once if it is not filled.

Edit Report (SQL). We will UNION with data and limit the output. LIMIT 10.

SELECT
    orders.id as "orders.id",
    orders.customerName as "orders.customerName",
    orders.orderDate as "orders.orderDate",   
    orders.salesRep as "orders.salesRep", 
    orderLines.qty as "orderLines.qty", 
    orderLines.number as "orderLines.number",
    orderLines.description as "orderLines.description",
    orderLines.price as "orderLines.price",
    NULL
FROM                                           
    orders
JOIN orderLines
    ON orderLines.id_orders=orders.id
WHERE
    orders.id=$id
UNION ALL
SELECT $id as "orders.id",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
num
FROM tenlines
ORDER BY 9 -- sort by 9 columns
LIMIT 10

OR without create table
It is irrational if the number of lines will be more. )

SELECT
    orders.id as "orders.id",
    orders.customerName as "orders.customerName",
    orders.orderDate as "orders.orderDate",   
    orders.salesRep as "orders.salesRep", 
    orderLines.qty as "orderLines.qty", 
    orderLines.number as "orderLines.number",
    orderLines.description as "orderLines.description",
    orderLines.price as "orderLines.price",
    null
FROM                                           
    orders
JOIN orderLines
    ON orderLines.id_orders=orders.id
WHERE
    orders.id=$id
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 2 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 3 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 5 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 6 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 8 as num
UNION ALL
SELECT $id as "orders.id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 9 as num 
ORDER BY 9 -- sort by 9 columns 
LIMIT 10  

And remove rows with NULL or create new table "orderLines". Remove procedure add NULL from script.
If you have any difficulties, I'll post a modified version.
I'll watch the report later.

812

(11 replies, posted in Reports)

it is possible in more detail about the 2nd method with an example?
what is needed ?

813

(11 replies, posted in Reports)

http://myvisualdatabase.com/forum/viewt … 7643#p7643

kunar80
На сколько я знаю, да, в Footer нельзя вывести данные из базы, можно только расчеты, или с помощью скрипта.

kunar80
As far as I knows, you cannot display data from the database in Footer, you can only use calculations, or using a script.


Maybe you can find a solution here

http://myvisualdatabase.com/forum/viewtopic.php?id=5919

814

(11 replies, posted in General)

without seeing your project in ehwagner code

Form1.edLatestDate.Text := DateToStr(SQLDateTimeToDateTime(SqlExecute('Select Max(TransDate) From Test')));

add WHERE.

 ... DateToStr(SQLDateTimeToDateTime(SqlExecute('Select Max(SvcDate) From tbl_Service WHERE id_tbl_Equip = your Equipment ID from frmService ')));

815

(3 replies, posted in General)

Maybe, maybe.

816

(2 replies, posted in General)

Yes you can.
You get the number from this field in string format. You need to use the StrToInt (field) function to convert to a number.

817

(3 replies, posted in General)

look here
http://myvisualdatabase.com/forum/viewtopic.php?id=4

procedure frm1oncl (Sender: TObject; Action: TCloseAction);
begin
  Action := caNone;
end;

...

begin

 Form1.OnClose := @frm1oncl;

end.

You are welcome

I will repeat again. )))  I recommend reading help about JOINs in SQL.
This AND ... part of the JOIN. Your two tables A006B and A006 have a common id_LU_010_Eye_Select.

820

(12 replies, posted in Russian)

А смотря где и для чего

Для Edit через OnKeyPress или OnKeyDown пример здесь

http://myvisualdatabase.com/forum/viewtopic.php?id=1879

For the Sex table (in Database tables), put Check - The table is a dictionary, and try now.

Try to fix your request like this.
Add last line "AND ..."
Hope this solves your problem)

...
where
A002.id = $id
AND A006B.id_LU_010_Eye_Select=A006.id_LU_010_Eye_Select
eyeman303 wrote:

Hello Sparrow,
Thank you for the response. I am indebted to you and all the learned Forum members and Derek, in particular for guiding me at every step in my projects. Definitely, I will read more about JOINs. The Report needs to display the data entered in all the child tables for an OPD_ID on a particular date. The A002.id is unique for each OPD_ID and date, and id_A002 is a foreign key in all the child tables. This query is getting additional data for A002.id  referring to a different OPD_ID and date. Why is this happening?
Regards,
Eyeman.

Hi,
Show exactly which column from the query or which row, which data ... you think is wrong. Then we can discuss.
In the file what your request returns (partially).

PS
see answer below

Hi,
Now your queries are referring to a table "invoices" that you do not have .
Let's try to do this.
You will make your program to the maximum.
Now you have everything separately in the program.
Invoice form in its infancy).
Complete the invoice form without the total quantity and amount, but with all the fields that are required. Which order, which client, which products, quantity, how they are displayed ... perhaps you will understand how to calculate the cost by quantity.
If not, then let's talk.

As Derek says I was waiting for this question
Derek did a lot for your project and maybe my questions and answers will help you, him and me.
You understood my answer correctly (Left Join may be ideal, as often the child tables may have a "null" value). But you still have to enter data correctly into your tables.
1.You have a lot of tables and it seems to me that you do not quite understand how JOIN works with all this.
   Without this, you will not be able to display data correctly.
   I recommend reading the help about all JOINs in SQL, especially about NULL and INER JOIN, LEFT JOIN.
2. You see A002.id as you set its ID in WHERE. But JOIN matching  data from other tables. Any condition in JOIN ... ON ... forces data to be matching values according to the equality ... = .... What you want to see is shown to you. Please read the help for all JOINs in SQL. It is not difficult.
3. Try to specify specifically in WHERE or SELECT what you want to get from ANY table. The last record by id, by time or other parameters ... I understand that it is difficult, there are many tables.
4. LEFT JOIN will most likely be perfect. But only in the case when not all tables are filled in correctly (I'm talking about "NULL" and "n / a" and ...). But this will not help to display correct data if it is missing.



When you read the JOIN help and try it yourself, be specific about what is wrong and what you want to see.  I or someone else will try to help. The forum reads and can help you better experts than me.

Sorry for my and google english).