Answer the question
In order to leave comments, you need to log in
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";
Запрос.УстановитьПараметр("ТабличнаяЧасть",Объект.ТабЧасть.Выгрузить());
РезультатЗапроса = Запрос.Выполнить();
Answer the question
In order to leave comments, you need to log in
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.
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 questionAsk a Question
731 491 924 answers to any question