I have an MS Access continuous form on onload event i am getting MyTable Record, upto here its fine. But i want to change the color of only first row
MyTable
Id ¦ Name ¦ Months ¦ Years
------------------
1 ¦ Ali ¦ 01 ¦ 2020
2 ¦ Umar ¦ 02 ¦ 2020
3 ¦ Abid ¦ 03 ¦ 2019
4 ¦ Sana ¦ 04 ¦ 2020
I used this code
Dim tblCount, Countr as Integer
tblCount = Dcount("Years", "MyTable")
For Countr = 1 to tbleCount
If countr = 1 Then
Me.Years.ForeColor = vbred
Else
Me.Years.ForeColor = vbblack
End If
Next Countr
When countr = 1 it shows all Years Column Red and when Countr > 1 Years Column becomes black
But i want only first row Years Red rest all rows Black
I really thankful to you plzz help me
Related
Help me with query. I need somehow group row but i dont know.
We have table with data of clients calls and this query need for statistic.
Condition: several calls from one person in some date range in one item.
table:
id id_person created_date
1 1 2019-01-01 10:10:10
2 1 2019-01-02 10:10:10
3 1 2019-01-02 10:15:10
4 1 2019-01-05 10:20:10
5 2 2019-01-01 10:10:10
6 2 2019-01-02 10:10:10
7 3 2019-01-02 10:15:10
For e.g. we set gap param in 3 days
result of query:
1 1 2019-01-01 10:10:10
4 1 2019-01-05 10:20:10
5 2 2019-01-01 10:10:10
7 3 2019-01-02 10:15:10
For e.g. we set gap param in 1 day
result of query:
1 1 2019-01-01 10:10:10
3 1 2019-01-02 10:15:10
4 1 2019-01-05 10:20:10
5 2 2019-01-01 10:10:10
7 3 2019-01-02 10:15:10
Need group by person_id and excepting rows that include in row.created_date+gap
Your question has been asked before:
This solution should solve your issue and you can apply whichever gap parameter you want: Link
SELECT
id_person,
created_date,
DATEADD(DAY, NoGroup*3, '1999-01-01') AS [Gap Start],
DATEADD(DAY, NoGroup*3+2, '1999-01-01') AS [Gap End],
SUM(DPT)
FROM
(
SELECT
id_person,
created_date,
DATEDIFF(DAY, '1999-01-01', created_date) AS NoDays,
DATEDIFF(DAY, '1999-01-01', created_date)/3 AS NoGroup,
DPT
FROM your_table
) subquery
GROUP BY
id_person,
created_date;
i have table with 3 columns , now how find value if it appears next 3 times immediately
date tran_val name
1 23mar 22 mark
2 24mar 22 mark
3 25mar 22 mark
4 26mar 22 mark
5 27mar 22 mark
6 28jan 99 john
7 29jan 99 john
8 30jan 99 john
9 31jan 99 john
output is like
date tran_val name
1 23mar 22 mark
2 24mar 22 mark
6 28jan 99 john
i.e 1st trnas_value appears in next 3 consecutive times (repeaded 4 times)
and 2nd and 6th also rows also repeaded the same..
thanks in advance
I have a table that is used to hold answers to questions. Each question can be answered at different time intervals. Here's the table structure I have:
entry_index | ques_idx | ques | ans_idx | ans | entry_time | usr_id
1 1 ques1.. 1 ans 1 14:00 usr1
2 2 ques2.. 4 ans 4 14:00 usr1
3 1 ques1.. 2 ans 2 13:00 usr1
4 2 ques2.. 3 ans 3 13:00 usr1
What I am attempting to do is display the questions with the answers and the entry times as a column. For example:
ques | 14:00 | 13:00
ques1.. ans 1 ans 2
ques2.. ans 4 ans 3
Would a join be appropriate for this? I am at a complete loss. Any help would be greatly appreciated.
i want to get the max(HA) and max(Total) of grouped by 'subject' for all students
for the given table
Date Sem Section Subject USN Name Status HA Total
-----------|------|----------------------------------------------------------------
2013-11-11 1 A c 01 Akshay present 1 2
2013-11-11 1 A c 02 David absent 1 2
2013-11-11 1 A .net 01 Akshay absent 1 2
2013-11-11 1 A .net 02 David present 2 2
2013-11-12 1 A c 01 Akshay absent 0 1
2013-11-12 1 A c 02 David present 1 1
2013-11-12 1 A .net 01 Akshay present 1 1
2013-11-12 1 A .net 02 David present 1 1
REsult should be:
Sem Section Subject USN Name HA Total
-----|--------|---------|------|--------|-----|------
1 A c 01 Akshay 1 2
1 A c 02 David 1 2
1 A .net 01 Akshay 1 2
1 A .net 02 David 2 2
Pls.. help...
select sem,section,subject,usn, Name, max(HA), MAX(total)
from table
group by sem, section, subject, usn, naam
I have to comapre the results relative to the same time between two tables, but the time stamps differs of some second because of how they were recorded.
I would like to obtain a result like in Example 1 but I get only the values with the asterisk, as in Example 2.
What is the best way to remove the secods from the comparison, or to select the value corresponding to the closest DATETIME value?
Currently I'm using this query:
SELECT Table1.TimeSTamp1, Table1.Param1, Table2.TimeStamp2, Table2.Param2
FROM Table1, Table2
WHERE ... conditions for the other parameters of Table1 and Table2...
AND Table1.TimeSTamp1 = Table2.TimeStamp2
Any suggestion on the best practice is warmly welcomed.
Example 1
TimeStamp1 ¦ Param1 ¦ TimeStamp2 ¦ Param2
2011-01-01 00:00:35 ¦ 1 ¦ 2011-01-01 00:00:35 ¦ a *
2011-01-01 00:01:35 ¦ 2 ¦ 2011-01-01 00:01:35 ¦ b
2011-01-01 00:02:37 ¦ 3 ¦ 2011-01-01 00:02:35 ¦ c
2011-01-01 00:03:31 ¦ 4 ¦ 2011-01-01 00:03:35 ¦ d
2011-01-01 00:04:32 ¦ 5 ¦ 2011-01-01 00:04:35 ¦ e
2011-01-01 00:05:38 ¦ 6 ¦ 2011-01-01 00:05:35 ¦ f
2011-01-01 00:06:36 ¦ 7 ¦ 2011-01-01 00:06:36 ¦ g *
2011-01-01 00:07:32 ¦ 8 ¦ 2011-01-01 00:07:35 ¦ h
2011-01-01 00:08:33 ¦ 9 ¦ 2011-01-01 00:08:35 ¦ i
2011-01-01 00:09:33 ¦ 10 ¦ 2011-01-01 00:09:33 ¦ l *
2011-01-01 00:10:35 ¦ 11 ¦ 2011-01-01 00:10:35 ¦ m *
2011-01-01 00:11:29 ¦ 12 ¦ 2011-01-01 00:11:31 ¦ n
lll
Example 2
TimeStamp1 ¦ Param1 ¦ TimeStamp2 ¦ Param2
2011-01-01 00:00:35 ¦ 1 ¦ 2011-01-01 00:00:35 ¦ a
2011-01-01 00:06:36 ¦ 7 ¦ 2011-01-01 00:06:36 ¦ g
2011-01-01 00:09:33 ¦ 10 ¦ 2011-01-01 00:09:33 ¦ l
2011-01-01 00:10:35 ¦ 11 ¦ 2011-01-01 00:10:35 ¦ m
This MySql expression will give you back DATETIME values with the seconds zeroed out.
CONVERT(DATE_FORMAT(table.column,'%Y-%m-%d-%H:%i:00'),DATETIME)
Take a look at this. https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format . So you might end up with a query like this:
SELECT Table1.TimeSTamp1, Table1.Param1, Table2.TimeStamp2, Table2.Param2
FROM Table1
JOIN Table2 ON CONVERT(DATE_FORMAT(Table1.TimeStamp1,'%Y-%m-%d-%H:%i:00'),DATETIME)
= CONVERT(DATE_FORMAT(Table2.TimeStamp2,'%Y-%m-%d-%H:%i:00'),DATETIME)
WHERE ... conditions for the other parameters of Table1 and Table2...
But, be careful. Autogenerated timestamps are kind of like floating point numbers; when two of them turn up equal to each other it's just luck. Truncating your timestamps to the minute may be OK, but you may also be better off subtracting one timestamp from another, and comparing the differences (or the absolute values of the differences).
Also, this join is going to be slow because it has to run the second-truncating function on every value, so it can't use any indexes.
You can subtract one timestamp from another with TIMESTAMPDIFF(). But be careful. This function only works correctly at the level of seconds for timestamps within a few days of each other; it overflows gracelessly (as I discovered with great pain).
You could try truncating the timestamps to minutes at the time you insert them. That would let you index them.
WHERE ...
AND ABS(UNIX_TIMESTAMP(TimeStamp1) - UNIX_TIMESTAMP(TimeStamp2)) < :threshold:
where threshold is the number of seconds after which you no longer want a match (e.g. 60 for 1 minute).
You could use TIMESTAMPDIFF to compute the difference in datetimes in seconds:
SELECT t1.TimeStamp1, t1.Param1, t2.TimeStamp2, t2.Param2
FROM Table1 t1
LEFT JOIN Table2 t2
ON ABS(TIMESTAMPDIFF(SECOND,t1.TimeStamp1,t2.TimeStamp2))<=4
WHERE ...
Noting Ollie Jones warning, I've tested TIMESTAMPDIFF on MySQL version 5.1.58 and found no overflow with timestamps differing by up to at least 10000 years. So maybe this problem has been fixed.