toadmr
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Приветствую! Не удается заполнить таблицу operations_data Таблица invoice_order_operations существует и в ней есть данные Создал таблицы-справочники и заполнил их Код: create table order_type ( order_type_id int identity(1,1) primary key, order_type varchar(50) ) insert into order_type (order_type) select distinct order_type from invoice_order_operations create table product_category ( product_category_id int identity(1,1) primary key, product_category varchar(50) ) insert into product_category (product_category) select distinct product_category from invoice_order_operations create table product ( product_id int identity(1,1) primary key, product varchar(50) ) insert into product (product) select distinct product from invoice_order_operations create table manufacturer ( manufacturer_id int identity(1,1) primary key, manufacturer varchar(50) ) insert into manufacturer (manufacturer) select distinct manufacturer from invoice_order_operations | Теперь нужно на основании таблицы источника и справочников заполнить таблицу operations_data Что-то в голову не идет, как это сделать, кроме как таким запросом: Код: create table operations_data ( dt date, tm time, order_number int, order_type_id int, product_category_id int, product_id int, manufacturer_id int, cnt int, price float, selling_price float ) insert into operations_data (dt, tm, order_number, cnt, price, selling_price, order_type_id, product_category_id, product_id, manufacturer_id) --select dt, tm, order_number, cnt, price, selling_price select * from invoice_order_operations t1 join order_type t2 on t1.order_type = t2.order_type join product_category t3 on t1.product_category = t3.product_category join product t4 on t1.product = t4.product join manufacturer t5 on t1.manufacturer = t5.manufacturer | Но среда ругается The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns. Понимаю, что какие-то столбцы не совпадают, но пока ума не приложу какие | Всего записей: 67 | Зарегистр. 12-04-2023 | Отправлено: 16:47 21-06-2025 | Исправлено: toadmr, 16:52 21-06-2025 |
|