Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

You're after the UPDATE FROM syntax.
***
UPDATE
table T1
SET
column1 = T2.column1
FROM
table T2
INNER JOIN table T3 USING (column2)
WHERE
T1.column2 = T2.column2;
***
4 years ago
This will give you BOTH the distinct column values and the count of each value.
***
SELECT [columnName], count([columnName]) AS CountOf
FROM [tableName]
GROUP BY [columnName]
***
4 years ago
Foreign keys allow key values that are all NULL, even if there are no matching PRIMARY or UNIQUE keys

No Constraints on the Foreign Key

When no other constraints are defined on the foreign key, any number of rows in the child table can reference the same parent key value. This model allows nulls in the foreign key. ...

NOT NULL Constraint on the Foreign Key

When nulls are not allowed in a foreign key, each row in the child table must explicitly reference a value in the parent key because nulls are not allowed in the foreign key.

Any number of rows in the child table can reference the same parent key value, so this model establishes a one-to-many relationship between the parent and foreign keys. However, each row in the child table must have a reference to a parent key value; the absence of a value (a null) in the foreign key is not allowed. The same example in the previous section can be used to illustrate such a relationship. However, in this case, employees must have a reference to a specific department.
4 years ago
Bless is a high quality, full featured hex editor.

It is written in mono/Gtk# and its primary platform is GNU/Linux. However it should be able to run without problems on every platform that mono and Gtk# run.

Bless currently provides the following features:

Efficient editing of large data files and block devices.
Multilevel undo - redo operations.
Customizable data views.
Fast data rendering on screen.
Multiple tabs.
Fast find and replace operations.
A data conversion table.
Advanced copy/paste capabilities.
Highlighting of selection pattern matches in the file.
Plugin-based architecture.
Export of data to text and HTML (others with plugins).
Bitwise operations on data.
A comprehensive user manual.

wxHexEditor is another Free Hex Editor, built because there is no good hex editor for the Linux system, especially for big files.

It uses 64-bit file descriptors (supports files or devices up to 2^64 bytes, which means some exabytes but tested only 1 PetaByte file (yet). ).
It does NOT copy the whole file to your RAM. That make it FAST and can open files (which sizes are Multi Giga < Tera < Peta < Exabytes)
Could open your devices on Linux, Windows, or MacOSX.
Memory Usage: Currently ~10 MegaBytes while opened multiple > ~8GB files.
Could operate thru XOR encryption.
Written with C++/wxWidgets GUI libs and can be used with other OSes such as Mac OS, Windows as a native application.
You can copy/edit your Disks, HDD Sectors with it.( Useful for rescue files/partitions by hand. )
You can delete/insert bytes to a file, more than once, without creating a temp file.

DHEX is more than just another hex editor: It includes a diff mode, which can be used to easily and conveniently compare two binary files. Since it is based on ncurses and is themeable, it can run on any number of systems and scenarios. With its utilization of search logs, it is possible to track changes in different iterations of files easily.
4 years ago
You could use a for-loop to loop through printing fields $2 through $NF (a built-in variable that represents the number of fields on the line).

Since "print" appends a newline, you'll want to buffer the results:
***
awk '{out=""; for(i=2;i<=NF;i++){out=out" "$i}; print out}'
***
Alternatively, use printf:
***
awk '{for(i=2;i<=NF;i++){printf "%s ", $i}; printf "\n"}'
***
4 years ago
Example of tokenizer
***
#include
#include
using namespace std;

vector split(const char *str, char c = ' ')
{
vector result;

do
{
const char *begin = str;

while(*str != c && *str)
str++;

result.push_back(string(begin, str));
} while (0 != *str++);

return result;
}
***
4 years ago
As the name implies, a double has 2x the precision of float[1]. In general, a double has 15 decimal digits of precision, while float has 7.

Here's how the number of digits are calculated:

double has 52 mantissa bits + 1 hidden bit: log(253)÷log(10) = 15.95 digits

float has 23 mantissa bits + 1 hidden bit: log(224)÷log(10) = 7.22 digits

This precision loss could lead to greater truncation errors being accumulated when repeated calculations are done, e.g.
***
float a = 1.f / 81;
float b = 0;
for (int i = 0; i < 729; ++ i)
b += a;
printf("%.7g\n", b); // prints 9.000023
***
while
***
double a = 1.0 / 81;
double b = 0;
for (int i = 0; i < 729; ++ i)
b += a;
printf("%.15g\n", b); // prints 8.99999999999996
***
Also, the maximum value of float is about 3e38, but double is about 1.7e308, so using float can hit "infinity" (i.e. a special floating-point number) much more easily than double for something simple, e.g. computing the factorial of 60.

During testing, maybe a few test cases contain these huge numbers, which may cause your programs to fail if you use floats.

Of course, sometimes, even double isn't accurate enough, hence we sometimes have long double[1] (the above example gives 9.000000000000000066 on Mac), but all floating-point types suffer from round-off errors, so if precision is very important (e.g. money processing) you should use int or a fraction class.

Furthermore, don't use += to sum lots of floating-point numbers, as the errors accumulate quickly. If you're using Python, use fsum. Otherwise, try to implement the Kahan summation algorithm.
4 years ago
The difference between class and struct in C++ is

Members of a class defined with the keyword class are private by default. Members of a class defined with the keywords struct or union are public by default.

The keyword class can be used to declare template parameters, while the struct keyword cannot be so used.
4 years ago
DDL is Data Definition Language : Specification notation for defining the database schema. It works on Schema level.

DDL commands are:
***
create,drop,alter,rename
***
For example:
***
create table account (
account_number char(10),
balance integer);
***
DML is Data Manipulation Language .It is used for accessing and manipulating the data.

DML commands are:
***
select,insert,delete,update,call
***
For example :
***
update account set balance = 1000 where account_number = 01;
***
4 years ago
If it is SQL Server 2017 or SQL Server Vnext, SQL Azure you can use string_agg as below:
***
select id, string_agg(concat(name, ':', [value]), ', ')
from #YourTable
group by id
***
4 years ago
From the phrasing of your question, I understand that you want to select the distinct values for a given field and for each such value to have all the other column values in the same row listed. Most DBMSs will allow this with neither DISTINCT nor GROUP BY because the result is not determined.

Think of it like this: if your field1 occurs more than once, what value of field2 will be listed (given that you have the same value for field1 in two rows but two distinct values of field2 in those two rows).

You can however use aggregate functions (explicitly for every field that you want to be shown) and using a GROUP BY instead of DISTINCT:
***
SELECT field1, MAX(field2), COUNT(field3), SUM(field4), .... FROM table GROUP BY field1
***
4 years ago
Here is another nice solution for the Max functionality using T-SQL and SQL Server
***
SELECT [Other Fields],
(SELECT Max(v)
FROM (VALUES (date1), (date2), (date3),...) AS value(v)) as [MaxDate]
FROM [YourTableName]
***
4 years ago