Stop duplicated indexing - ms-access

I am trying to stop duplicate entry's into my database (below). eg it will come up with an error message if the vechID, Collection date, and return date is the same. I am opening my table in design view and clicking indexes and then indexing the relevant fields. but it wont work let me and keeps saying no due to duplicate values. is this the correct method
Booking ID VechID CuID Collection date Return date
1 3 7 01/07/2017 10/07/2018
2 1 7 23/04/2017 16/05/2018
3 2 1 17/05/2017 28/05/2018
4 4 2 15/05/2017 20/05/2018
5 5 2 01/06/2017 24/06/2018
6 6 2 22/07/2017 29/08/2018
7 4 8 01/07/2017 15/07/2018
8 8 8 01/08/2017 20/08/2018
9 8 2 21/01/2017 20/01/2018
10 4 8 25/09/2017 02/10/2018
13 8 8 25/09/2017 02/10/2018

Yes, you need to create a unique index on the fields (vechID, Collection date, return date).
Of course you can't do that if you already have data in your table that violates this unique index.
Use the query wizard for Duplicate Search to find and delete them.

Related

what is the correct way to select the highest value from column not primary key

I have a table (report) consist of several records and one of them about int values (column) I am trying to get the highest number of the fall_value column the id only primary key, the table as following:
id (P)
fall_value
date
3
1.2
2021-01-29
4
1.5
2021-01-30
5
1.6
2021-01-30
6
1
2021-01-31
7
5
2021-01-31
8
1.5
2021-01-31
9
1.5
2021-01-31
10
14
2021-01-31
11
15
2021-01-31
expected result: 15
I have tried the following inquiry:
SELECT max(fall_value) from report;
I got an unexpected result: 5
and also I got a message saying:
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available
It sounds like fall_value is a string, not a number, and the string "5" is indeed greater than the string "15".
Try converting to a number. A convenient way is to use implicit conversion:
SELECT max(fall_value + 0)
FROM report;

Algorithm for splitting date according to new record

In my mysql database
I have to write stored procedure.
I have table DATE which has 4 Columns
Table: DATE
Sq number(auto generated) From_Date To_date value
2 20170112 20170115 3
3 20170116 20170220 5
4 20170221 20170301 7
and so on
so if I get data which has to be added to table
from and to as 20170119 and 20170201 and value 6
then my table should look like
Table:DATE
Sq number(auto generated) From_Date To_date value
2 20170112 20170115 3
3 20170116 20170118 5
4 20170221 20170301 7
5 20170119 20170201 6
6 20170202 20170220 5
is there any algorithm or any logic to implement this kind of situation and handle all other possibilities
Not an answer, but too long for a comment...
If it was me, I'd revise the question, e.g.
start_val end_val
3 5
6 11
What would be the effect of bringing the values 4 and 8 into this table?

mysql how do I detect missing values from the sequence?

im making a url shortener and im using the id for my hash
but theres a problem with auto incre mysql
URL tabel
id short_hashbase62
1 1
2 2
3 3
4 4
6 6
7 7
8 8
12 c
the missing values are 5 and 9 10 11
question: how could i select the 5 with mysql? then the second select should be 9, and forth on.
there are some similar question but its to complex to understand;
Detect missing values in a (auto-incremented) sequence
Aligning sequences with missing values

How to apply a formula for removing data noise in R?

I am working on NGSim Traffic data, having 18 columns and 1180598 rows in a text file. I want to smooth the position data, in the column 'Local Y'. I know there are built-in functions for data smoothing in R but none of them seem to match with the formula I am required to apply. The data in text file looks something like this:
Index VehicleID Total_Frames Local Y
1 2 5 35.381
2 2 5 39.381
3 2 5 43.381
4 2 5 47.38
5 2 5 51.381
6 4 8 504.828
7 4 8 508.325
8 4 8 512.841
9 4 8 516.338
10 4 8 520.854
11 4 8 524.592
12 4 8 528.682
13 4 8 532.901
14 5 7 39.154
15 5 7 43.153
16 5 7 47.154
17 5 7 51.154
18 5 7 55.153
19 5 7 59.154
20 5 7 63.154
The above data columns are just example taken out of original file. Here you can see 3 vehicles, with vehicle IDs = 2, 4 and 5 but in fact there are 2169 vehicles with different IDS. The column Total_Frames tell us how many times vehicle Id of each vehicle is repeated in the first column, for example in the table above, vehicle ID 2 is repeated 5 times, hence '5' in Total_Frames column. Following is the formula I am required to apply to remove data noise (smoothing) from column 'Local Y':
Smoothed Position Value = (1/(Summation of [EXP^-abs(i-k)/delta] from k=i-D to i+D)) * ( (Summation of (Local Y) *[EXP^-abs(i-k)/delta] from k=i-D to i+D))
where,
i = index #
delta = 5
D = 15
I have tried using the built-in functions, which I know of, but they don't smooth the data as required. My question is: Is there any built-in function in R which can do the data smoothing in the way of given formula or which could take this formula as an argument? I need to apply the formula to every value in Local Y which has 15 values before and 15 values after them (i-D and i+D) for same vehicle Id. Can anyone give me any idea how to approach the problem? Thanks in advance.
You can place your formula in a function and then use the apply function of R to apply it to the elements in your "Local Y" column of the dataframe

Add together grouped rows into one value

I've got an issue where I've been presented data in this format from SQL, and have directly imported that into SSRS 2008.
I do have access to the stored procedure for this report, however I don't want to change it as a few other reports rely on it.
Project HoursSpent Cost
1 5 45
1 8 10
1 7 25
1 5 25
2 1 15
2 3 10
2 5 15
2 6 10
3 6 10
3 4 5
3 4 10
3 2 5
I've been struggling all morning to understand how/when I should be implementing the SUM() function with this.
I have tried already to SUM() the rows, but it still outputs the above result.
Should I be adding any extra groups?
Ideally, I need to have the following output:
Project HoursSpent Cost
1 25 105
2 15 40
3 16 30
EDIT: Here is my current structure:
"LineName" is a group for each project
You have to add a row group on "Project" since you want to sum up the data per each project.