Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED] SQLite and 2 decimals
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
When will lazarus actuall...
by
marcov
[
Today
at 05:52:04 pm]
Bug with constref?
by
marcov
[
Today
at 05:46:33 pm]
Anubis activated
by
T-Khan
[
Today
at 04:45:39 pm]
PopupMenu on dock menu
by
wp
[
Today
at 04:13:34 pm]
FPC Unleashed (inline var...
by
Okoba
[
Today
at 03:49:31 pm]
Can I enter MySQL prompt ...
by
nikel
[
Today
at 03:41:56 pm]
is this code correct?
by
Thaddy
[
Today
at 03:23:29 pm]
Anubis's website security...
by
ALLIGATOR
[
Today
at 02:45:52 pm]
Pure Pascal LZ4, LZ5 and ...
by
LemonParty
[
Today
at 01:38:07 pm]
Linking a PortAudio stati...
by
Thaddy
[
Today
at 10:52:31 am]
TShellTreeView TopItem
by
Paolo
[
Today
at 10:07:58 am]
Temp file CGI00000.TMP
by
Thaddy
[
Today
at 09:32:16 am]
Nothing but chaotic attem...
by
LeP
[
Today
at 09:02:05 am]
Feature suggestion - repe...
by
paweld
[
Today
at 07:38:10 am]
search via TSQLQuery
by
paweld
[
Today
at 07:28:41 am]
Amigo programming languag...
by
paxscript
[
Today
at 05:49:02 am]
Klondike solitaire Part 2
by
valdir.marcos
[
Today
at 03:50:07 am]
Creation of LAMW [NoGUI] ...
by
neuro
[
Today
at 01:06:41 am]
wildcard utilities list
by
mas steindorff
[
Today
at 12:22:21 am]
Artificial Intelligence a...
by
LeP
[May 16, 2026, 06:15:13 pm]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[May 16, 2026, 04:39:24 pm]
Read/Parse PDB file to ge...
by
LeP
[May 16, 2026, 04:12:58 pm]
Dark Theme
by
NickyTi
[May 16, 2026, 04:11:34 pm]
StringGrid: which is "cur...
by
jamie
[May 16, 2026, 04:10:34 pm]
Can /my/ AI help me with ...
by
microxa
[May 16, 2026, 03:51:48 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] SQLite and 2 decimals (Read 9673 times)
madref
Hero Member
Posts: 1116
..... A day not Laughed is a day wasted !!
[SOLVED] SQLite and 2 decimals
«
on:
March 10, 2016, 09:14:14 pm »
I am using this SQL-statement to create a query/view.
Code: SQL
[Select]
[+]
[-]
SELECT
Wed_Meetellen
,
Scheidsrechter
AS
Referee
,
COUNT
(
Scheids_ID
)
AS
Games
,
SUM
(
Vergoeding_Wed
)
AS
Fee
,
SUM
(
Vergoeding_KM
)
AS
Milage
FROM
qry_Temp_Uitbetalen
WHERE
ABS
(
Wed_Meetellen
)
=
1
GROUP
BY
Scheidsrechter
ORDER
BY
Scheidsrechter;
This outlines all the numbers on the right and i have decimal numbers like 100.1
I want to have to digits after the point (like 100.10).
With the following code i can get the 2 digits decimals but it lines the column out to the left side.
Code: SQL
[Select]
[+]
[-]
SELECT
Wed_Meetellen
,
Scheidsrechter
AS
Referee
,
COUNT
(
Scheids_ID
)
AS
Games
,
printf
(
"%.2f"
,
SUM
(
Vergoeding_Wed
)
)
AS
Fee
,
SUM
(
Vergoeding_KM
)
AS
Milage
FROM
qry_Temp_Uitbetalen
WHERE
ABS
(
Wed_Meetellen
)
=
1
GROUP
BY
Scheidsrechter
ORDER
BY
Scheidsrechter;
Question
: How can i get a 2 digit decimal AND the column is outlined to the right?
«
Last Edit: March 12, 2016, 07:47:25 pm by madref
»
Logged
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.
Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa
Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)
balazsszekely
Guest
Re: SQLite and 2 decimals
«
Reply #1 on:
March 11, 2016, 05:05:41 am »
For each field in the query you have a DisplayFormat property + the OnGetText event. Use one of those to format the output. Even more, you have the Alignment property to change the alignment(left, center, right).
Logged
madref
Hero Member
Posts: 1116
..... A day not Laughed is a day wasted !!
Re: SQLite and 2 decimals
«
Reply #2 on:
March 11, 2016, 05:43:24 am »
I have the following DBGrid and its linked to the rest.
Code: Pascal
[Select]
[+]
[-]
DBGrid_Evaluaties
:
TDBGrid
;
DS_Evaluaties
:
TDataSource
;
TQ_Evaluaties
:
TSQLQuery
;
Could you give me an example because i don't know how to address both
Logged
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.
Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa
Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)
balazsszekely
Guest
Re: SQLite and 2 decimals
«
Reply #3 on:
March 11, 2016, 06:19:37 am »
I don't know how can I be more specific:
https://youtu.be/n4WW5XxLsMc
PS: For formating use the DisplayFormat or the OnGetText event not both.
Logged
madref
Hero Member
Posts: 1116
..... A day not Laughed is a day wasted !!
Re: SQLite and 2 decimals
«
Reply #4 on:
March 11, 2016, 07:21:29 am »
Yes.. now i see....
But this is all in design time.
I am making my query in runtime so i don't have the fields at design time.
This is my code.....
But then i am stuck
Code: Pascal
[Select]
[+]
[-]
TQ_Evaluaties
.
Active
:
=
False
;
cSQL
:
=
'SELECT '
+
'Wed_Meetellen, Scheidsrechter AS Referee, COUNT(Scheids_ID) AS Games, '
+
'SUM(Vergoeding_Wed) AS Fee, '
+
'PRINTF("%.2f", SUM(Vergoeding_KM)) AS Milage '
+
'FROM qry_Temp_Uitbetalen '
+
'WHERE ABS(Wed_Meetellen) = 1 '
+
'GROUP BY Scheidsrechter '
+
'ORDER BY Scheidsrechter;'
;
TQ_Evaluaties
.
DataBase
:
=
Form_Information
.
Connect_RefereeDB
;
TQ_Evaluaties
.
SQL
.
Text
:
=
cSQL
;
TQ_Evaluaties
.
Active
:
=
True
;
Logged
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.
Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa
Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)
balazsszekely
Guest
Re: SQLite and 2 decimals
«
Reply #5 on:
March 11, 2016, 07:42:23 am »
You can also access those properties at runtime:
Code: Pascal
[Select]
[+]
[-]
TQ_Evaluaties
.
Fields
[
I
]
.
Alignment
:
=
taLeftJustify
;
Label1
.
Caption
:
=
Format
(
'...'
,
TQ_Evaluaties
.
FieldByName
(
'Vergoeding_Wed'
)
.
AsFloat
)
;
«
Last Edit: March 11, 2016, 08:17:16 am by GetMem
»
Logged
mangakissa
Hero Member
Posts: 1131
Re: SQLite and 2 decimals
«
Reply #6 on:
March 11, 2016, 09:16:54 am »
It's not really created in runtime
Bu I know what you mean. Also in runtime you can format your decimals
Code: Pascal
[Select]
[+]
[-]
TFloatfield
(
TQ_Evaluaties
.
FieldByName
(
'Vergoeding_Wed'
)
)
.
Displayformat
:
=
'####0.00'
;
Logged
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1
madref
Hero Member
Posts: 1116
..... A day not Laughed is a day wasted !!
Re: SQLite and 2 decimals
«
Reply #7 on:
March 12, 2016, 07:47:14 pm »
Thanx everyone
Logged
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.
Main Platform:
--------------
Mac OS X Tahoe 26.2
Lazarus 4.99 (rev main_4_99-3149-g7867f6275c) FPC 3.3.1 x86_64-darwin-cocoa
Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED] SQLite and 2 decimals
TinyPortal
© 2005-2018