1

Topic: Help with logic of request

Good afternoon!
Prompt please how correctly to make request
For example, there is a table with 2 columns
Names the Total
Andryukha 100
200
100
200
Question:
Whether it is possible to group the first column through LIKE clause and to count an amount and the total?
For example (does not work):
SELECT ' Sergey ' as [Names], SUM (IFF ([NAMES] LIKE "Sulfurs???", 1,0) as everything], SUM [Total] as [Total]
From [Table]
GROUP BY ' Sergey'
UNION ALL
SELECT ' Andrey ' as [Names], SUM (IFF ([NAMES] LIKE "Andr???", 1,0) as Everything], SUM [Total] as [Total]
From [Table]
GROUP BY ' Andrey'
In advance thanks!

2

Re: Help with logic of request

2017;
Error at you that, for example, on GROUP BY ' Sergey ' groupings will not be, for it not field name. And select you try to do not on field name, and on contents.
If by an example so it is possible:

SELECT IIf ([Names] Like "Andr *", "Andr", "Sulfurs") AS Imena2, Sum (the Table. The total) AS [Sum-]
FROM the Table
GROUP BY IIf ([Names] Like "Andr *", "Andr", "Sulfurs");

Or, if some names on first three characters it is possible:

SELECT Left ([Names], 3) AS Imena2, Sum (the Table. The total) AS [Sum-]
FROM the Table
GROUP BY Left ([Names], 3);

Here a trick that if there will be names, for example, Nikolay and Nikita, they will be grouped in first three characters of "Nik" and the total will be incorrect as will be considered on both names.

3

Re: Help with logic of request

2017 wrote:

Prompt please, as correctly

Correctly - to have the correspondence table  a name to a reference spelling.

4

Re: Help with logic of request

Akina;
I understand that it would be correct, but the table with names - for an example.
In practice the template will be used for BIN'S identification of a considerable quantity of cards on the first 6 digits, remaining digits can differ, in this connection the question has been asked

5

Re: Help with logic of request

2017 wrote:

In practice the template will be used for BIN'S identification of a considerable quantity of cards on the first 6 digits, remaining digits can differ, in this connection the question

And for this reason it was necessary to invent so inadequate model has been asked? On your happiness, a companion 777888 appeared penetrating enough to give the decision (the second request in the answer).

6

Re: Help with logic of request

777888;
Thanks, work-)