V
V
Vladislav2016-01-18 12:02:42
SQL
Vladislav, 2016-01-18 12:02:42

How to correctly make a query and get the number of duplicate elements in a table (temporary)?

I have a processing with a tabular part of the document. The tabular part includes two
attributes - LineNumber
- StringTabPart The
StringTabPart is filled with characters randomly.
I need to display all duplicate elements in a table with a query:
My attempt is:

МенВрТаб = Новый МенеджерВременныхТаблиц;   		
Макет = Обработки.ПроизвольнаяОбработка.ПолучитьМакет("Макет");	
Запрос = Новый Запрос;
Запрос.МенеджерВременныхТаблиц = МенВрТаб;
Запрос.Текст = 
    "ВЫБРАТЬ 
    |  НомерСтроки,
    |  СтрокаТабЧасти
    |ПОМЕСТИТЬ
    |  ВременнаяТаблица 
    |ИЗ 
    |  &ТабличнаяЧасть КАК ТабличнаяЧасть;
    |ВЫБРАТЬ 
    |  СтрокаТабЧасти,
    |  КОЛИЧЕСТВО(НомерСтроки)
    |ИЗ 
    |  ВременнаяТаблица КАК ВременнаяТаблица
    |СГРУППИРОВАТЬ ПО
    |  СтрокаТабЧасти
    |ИМЕЮЩИЕ 
    |  КОЛИЧЕСТВО(НомерСтроки)>1"; 
Запрос.УстановитьПараметр("ТабличнаяЧасть",Объект.ТабЧасть.Выгрузить());	
РезультатЗапроса = Запрос.Выполнить();

Result:
e9ca17ef9213463c9dfc0be425590893.jpg
Download EPF: Processing

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kinash, 2016-01-18
@OnlyBooid

I didn't download the processing, but it's enough to look at the request:
1) You managed to create such a request using the constructor only because the constructor did not know the types of the props of the incoming table. If it were some kind of reference from the configuration, then you would immediately be given the answer that in the expression "Different" you cannot use lines of unlimited length.
2) The SQL knowledge examiners wanted to test your possession not of the DISTINCT statement, but of the HAVING statement.

G
Grigory Gusev, 2016-01-30
@Grigory_1C

If the stringtab is of unlimited length, you can try to express (... What string(100))
And it should work. Like...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question