i have an asp.net project,on this project,
i need to update my column according to values of my other 2 columns.
Structure of my table looks ;
ID - NAME - GK - PG - GK+PG
1 - mike - 1 - 1 [the sql should write here 540 but writes 180 for the case]
2 - john - 2 - 1 [the sql should write here 1080 but writes 180 for the case]
3 - sue - 1 - 2 [the sql should write here 1080 but writes 180 for the case]
Here is the .cs code for it.
string strSQL = "UPDATE [info] SET
[GK_PG] = (CASE
WHEN ([GK]='1') THEN '180'
WHEN ([PG]='1') THEN '180'
WHEN ([GK]='2') THEN '540'
WHEN ([PG]='2') THEN '540'
WHEN ([GK]='3') THEN '1080'
WHEN ([PG]='3') THEN '1080'
WHEN ([GK]='1' AND [PG]='1') THEN '540'
WHEN ([GK]='2' AND [PG]='1') THEN '1080'
WHEN ([GK]='1' AND [PG]='2') THEN '1080'
ELSE 0
END)
WHERE [DATE] BETWEEN #DATE1 AND #DATE1 AND WORK_TYPE='IN'";
This code just writes the my [GK_PG] column '180', it doesnt look for other statuses.
Waiting your answer.
Thank you.
I've solved it by seperating GK and PG situations into the 2 different button click event.
Thanks anyway.
Related
while working on the exercise 2.2 of "programming in Lua 4" I do have to create a function to built all permutations of the numbers 1-8. I decided to use Heaps algorithm und made the following script. I´m testing with numbers 1-3.
In the function I store the permutations as tables {1,2,3} {2,1,3} and so on into local "a" and add them to global "perm". But something runs wrong and at the end of the recursions I get the same permutation on all slots. I can´t figure it out. Please help.
function generateperm (k,a)
if k == 1 then
perm[#perm + 1] = a -- adds recent permutation to table
io.write(table.unpack(a)) -- debug print. it shows last added one
io.write("\n") -- so I can see the algorithm works fine
else
for i=1,k do
generateperm(k-1,a)
if k % 2 == 0 then -- builts a permutation
a[i],a[k] = a[k],a[i]
else
a[1],a[k] = a[k],a[1]
end
end
end
end
--
perm = {}
generateperm(3,{1,2,3}) -- start
--
for k,v in ipairs (perm) do -- prints all stored permutations
for k,v in ipairs(perm[k]) do -- but it´s 6 times {1,2,3}
io.write(v)
end
io.write("\n")
end
debug print:
123
213
312
132
231
321
123
123
123
123
123
123
I'm using an Hash Table to store some values. Here are the details:
There will be roughly 1M items to store (not known before, so no perfect-hash possible).
Table is 10M large.
Hash function is MurMurHash3.
I did some tests and storing 1M values I get 350,000 collisions and 30 elements at the most-colliding hash table's slot.
Are these result good?
Would it make sense to implement Binary Search for lists that get created at colliding hash-table's slots?
What' your advice to improve performances?
EDIT: Here is my code
var
HashList: array [0..10000000 - 1] of Integer;
for I := 0 to High(HashList) do
HashList[I] := 0;
for I := 1 to 1000000 do
begin
Y := MurmurHash3(UIntToStr(I));
Y := Y mod Length(HashList);
Inc(HashList[Y]);
if HashList[Y] > 1 then
Inc(TotalCollisionsCount);
if HashList[Y] > MostCollidingSlotItemCount then
MostCollidingSlotItemCount := HashList[Y];
end;
Writeln('Total: ' + IntToStr(TotalCollisionsCount) + ' Max: ' + IntToStr(MostCollidingSlotItemCount));
Here is the result I get:
Total: 48169 Max: 5
Am I missing something?
This is what you get when you put 1M items randomly into 10M cells
calendar_size=10000000 nperson = 1000000
E/cell| Ncell | frac | Nelem | frac |h/cell| hops | Cumhops
----+---------+--------+----------+--------+------+--------+--------
0: 9048262 (0.904826) 0 (0.000000) 0 0 0
1: 905064 (0.090506) 905064 (0.905064) 1 905064 905064
2: 45136 (0.004514) 90272 (0.090272) 3 135408 1040472
3: 1488 (0.000149) 4464 (0.004464) 6 8928 1049400
4: 50 (0.000005) 200 (0.000200) 10 500 1049900
----+---------+--------+----------+--------+------+--------+--------
5: 10000000 1000000 1.049900 1049900
The left column is the number of items in a cell. The second: the number of cells having this itemcount.
WRT the binary search: it is obvious that for small tables like this (maximum chain length=4, but most chains are of length=1), linear search outperforms binary search. The takeover-point is probably somewhere between 10 and 100.
When using autoIt to get Window's Text and the WinGetText matches multiple controls (e.g. with the same Class SciCalc in this case), the WinGetText will concatenate the text of all the controls. How can I get the Text of the n-th (say 3rd 'MR') control?
e.g.
Local $output = WinGetText("[CLASS:SciCalc]", "")
print
output:666666.
MC
MR
MS
M+
7
4
1
0
8
5
2
+/-
9
6
3
.
/
*
-
+
=
Backspace
CE
C
1/x
sqt
%
Something like this
ControlGetText("[CLASS:SciCalc]","","[CLASS:Button; INSTANCE:3]")
Use AutoIt Window Info to find the Advanced mode details on the wanted control.
I am running neo-4j 1.8.2 on a remote unix box. I am using this jar (https://github.com/jexp/batch-import/downloads).
nodes.csv is same as given in example:
name age works_on
Michael 37 neo4j
Selina 14
Rana 6
Selma 4
rels.csv is like this:
start end type since counter:int
1 2 FATHER_OF 1998-07-10 1
1 3 FATHER_OF 2007-09-15 2
1 4 FATHER_OF 2008-05-03 3
3 4 SISTER_OF 2008-05-03 5
2 3 SISTER_OF 2007-09-15 7
But i am getting this exception :
Using Existing Configuration File
Total import time: 0 seconds
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenizer.java:332)
at org.neo4j.batchimport.Importer$Data.split(Importer.java:156)
at org.neo4j.batchimport.Importer$Data.update(Importer.java:167)
at org.neo4j.batchimport.Importer.importNodes(Importer.java:226)
at org.neo4j.batchimport.Importer.main(Importer.java:83)
I am new to neo4j, was checking if this importer can save some coding effort.
It would be great if someone can point to the probable mistake.
Thanks for help!
--Edit:--
My nodes.csv
name dob city state s_id balance desc mgr_primary mgr_secondary mgr_tertiary mgr_name mgr_status
John Von 8/11/1928 Denver CO 1114-010 7.5 RA 0023-0990 0100-0110 Doozman Keith Active
my rels.csv
start end type since status f_type f_num
2 1 address_of
1 3 has_account 5 Active
4 3 f_of Primary 0111-0230
Hi I had some issues in the past with the batch import script.
The formating of your file must be very rigorous, which means :
no extra spaces where not expected, like the ones I see in the first line of your rels.csv before "start"
no multiple spaces in place of the tab. If your files are exactly like what you've copied here, you have 4 spaces instead of on tab, and this is not going to work, as the script uses a tokenizer looking for tabs !!!
I had this issue because I always convert tabs to 4 spaces, and once I understood that, I stopped doing it for my csv !
Hi I have products that are made up of a couple of options. Each Option has a SKU Code. You can only select one option from each SKU Group and the options have to be concatenated in the order of the SKUGroup.
So for example i would have a list of options in a table in the DB that looked like
OptID PID SKU Price SKUGroup
156727 93941 C 171.00 1
156728 93941 BN 171.00 1
156729 93941 PN 171.00 1
156718 93940 W 115.20 2
156719 93940 CA 115.20 2
156720 93940 BA 115.20 2
156721 93940 BNA 115.20 2
156722 93940 BN 115.20 2
156723 93940 BS 115.20 2
156716 93939 CHR 121.50 3
156717 93939 NK 138.00 3
And a few finished product SKUs would look something like:
C-W-CHR 407.70
C-W-NK 424.20
C-CA-CHR 407.20
C-CA-NK 424.20
I am trying to make a script that will create a listing of every possible combination of SKU and the price of the combined options.
I need this done in Classic ASP (vbscript) and I'm not that familiar with it. So I'm looking for all the help I can get.
Thanks!
I would start by connecting to the database and creating three recordsets.
Set connection = CreateObject("ADODB.Connection")
connection.Open ConnectionString
Set rsOption1 = CreateObject("ADODB.recordset")
Set rsOption2 = CreateObject("ADODB.recordset")
Set rsOption3 = CreateObject("ADODB.recordset")
rsOption1.Open "SELECT * FROM TableName WHERE SKUGroup = 1", connection, 3,3
rsOption2.Open "SELECT * FROM TableName WHERE SKUGroup = 2", connection, 3,3
rsOption3.Open "SELECT * FROM TableName WHERE SKUGroup = 3", connection, 3,3
Then you can use nested loops to get the combinations. Something like this (Untested, this probably will not work as is, but it gives you an idea of how to do this) (Also this assumes that you have to select at least one option from each group)
for i = 0 to rsOption1.RecordCount
rsOption1.Move i, 1
for j = 0 to rsOption2.RecordCount
rsOption2.Move j, 1
for k = 0 to rsOption3.RecordCount
rsOption3.Move k, 1
'Write rsOption1.Fields(2).Value & "-" & rsOption2.Fields(2).Value & _
'"-" & rsOption3.Fields(2).Value & " " & _
'FormatCurrency((rsOption1.Fields(3).Value + rsOption2.Fields(3).Value + rsOption3.Fields(3).Value))
Next
Next
Next