IT NOTES CODEx
IT NOTES CODEx
begin end;
TObject); end;
begin end;
end; begin
redOutput.Clear; begin
redOutput.Lines.Add('TotalRec tblRentals.Insert;
ords = ' +
tblRentals['Vehicle_ID'] := tblRentals['Start_Date'] :=
strtoint(edtVe strToDate(edtStart_Date.Text)
;
hicle_ID.Text);
tblRentals['Stop_Date'] :=
tblRentals['Driver_ID'] :=
strToDate(edtStop_Date.Text);
strtoint(edtDriver_ID.Text);
tblRentals.Post;
tblRentals['Start_Km'] :=
strtoint(edtStart_Km.Text); redOutput.Clear;
tblRentals['Stop_Km'] := redOutput.Lines.Add('New
strtoint(edtStop_Km.Text); Record Succesfully
tblRentals['Start_Date'] := Edited');
strToDate(edtStart_Date.Text)
end;
;
DELETE A RECORD FROM THE
tblRentals['Stop_Date'] :=
TABLE
strToDate(edtStop_Date.Text);
procedure
tblRentals.Post;
TfrmCarRent.btnDeleteYearTwen
end; tyClick(Sender: TObject);
Edit Recrods in a table var iCount : integer;
procedure begin
TfrmCarRent.btnEditClick(Send
iCount := 0;
er:
tblRentals.First;
TObject);
while not tblRentals.Eof do
begin
begin
tblRentals.Edit;
if
tblRentals['Vehicle_ID'] :=
pos('2020',datetostr(tblRenta
strtoint(edtVe
ls['Start_Date'])) > 0 then
hicle_ID.Text);
begin
tblRentals['Driver_ID'] :=
tblRentals.Delete;
strtoint(edtDriver_ID.Text);
inc(iCount);
tblRentals['Start_Km'] :=
strtoint(edtStart_Km.Text); tblRentals.First;
tblRentals['Stop_Km'] := end;
strtoint(edtStop_Km.Text);
tblRentals.Next;
end;
redOutput.Lines.Add(inttostr(
iCount) + ' Records
Deleted');
end;
SQL column, you must use the
Group By Statement
Aggregate Functions
Find how many times the "Cha-
An aggregate function
Cha" was
performs some mathematic
operations on a column. danced per week :
Usage : SELECT
Week,Count(TypeOfDance) from
SELECT
tblResults where
AggregateFunction(ColumnName)
TypeOfDance='Cha-Cha' GROUP
FROM
BY
tableName;
Week;
Min : Returns the minimum
Find how many couples where
value from a column:
Eliminated
SELECT MIN(Score) from
per week:
tblResults;
SELECT Week,Count(Result)
Max : Return the maximum
from tblResults
value from a column:
WHERE Result="Eliminated"
SELECT MAX(Score) from
GROUP BY Week;
tblResults;
Find which TypeOfDance
Sum : Returns the sum from a
yielded the
column :
highest score :
SELECT SUM(Score) from
tblResults; SELECT TypeOfDance,AVG(Score)
FROM tblResults GROUP BY
Avg : Returns the average
TypeOfDance ORDER BY AVG(-
from a column :
Score) desc;
SELECT AVG(Score) from
tblResults; As
Score),"0.000") AS condition;
AverageScore FROM
For every TypeOfDance, get
tblResults GROUP BY the Max Score
DanceCoupleID;
that is greater than 35:
Using Format with "Currency":
SELECT TypeOfDance,MAX(Score)
SELECT MONTH(PaymentDate) as FROM tblResults GROUP BY
MonthNum TypeOfDance HAVING MAX