从嵌套语法中选择语法的Vb.net问题:
SELECT derivedtbl_2.amel_code,
derivedtbl_2.kala_code,
derivedtbl_2.kala_name,
derivedtbl_2.kala_unit,
derivedtbl_2.kala_price,
Sum(derivedtbl_2.sum_qty_amani) AS
sum_qty_amani,
Sum(derivedtbl_2.sum_price_amani) AS
sum_price_amani,
Sum(dbo.sales_view.sum_qty_sales) AS
sum_qty_sales,
Sum(derivedtbl_2.sum_qty_amani - dbo.sales_view.sum_qty_sales) AS
remaining_qty_amani,
( derivedtbl_2.sum_qty_amani - dbo.sales_view.sum_qty_sales ) *
derivedtbl_2.kala_price AS
remaining_price_amani
FROM (SELECT amel_code,
kala_code,
kala_name,
kala_unit,
kala_price,
Sum(sum_qty_amani) AS sum_qty_amani,
Sum(sum_price_amani) AS sum_price_amani
FROM (SELECT dbo.amel_kala_amani_tbl.amani_code,
dbo.amel_kala_amani_tbl.amel_code,
dbo.amel_kala_amani_tbl.kala_code,
dbo.kala_price_active_view.kala_name,
dbo.kala_price_active_view.kala_unit,
dbo.kala_price_active_view.kala_price,
Sum(dbo.amel_kala_amani_tbl.qty)
AS sum_qty_amani,
Sum(dbo.amel_kala_amani_tbl.qty *
dbo.kala_price_active_view.kala_price)
AS
sum_price_amani
FROM dbo.amel_kala_amani_tbl
INNER JOIN dbo.kala_price_active_view
ON dbo.amel_kala_amani_tbl.kala_code =
dbo.kala_price_active_view.kala_code
GROUP BY dbo.amel_kala_amani_tbl.amani_code,
dbo.amel_kala_amani_tbl.amel_code,
dbo.kala_price_active_view.kala_name,
dbo.kala_price_active_view.kala_unit,
dbo.kala_price_active_view.kala_price,
dbo.amel_kala_amani_tbl.kala_code
HAVING ( dbo.amel_kala_amani_tbl.amani_code < @Param1 )
AND ( dbo.amel_kala_amani_tbl.amel_code = @Param2 )) AS
derivedtbl_1
GROUP BY amel_code,
kala_code,
kala_name,
kala_unit,
kala_price) AS derivedtbl_2
INNER JOIN dbo.sales_view
ON derivedtbl_2.amel_code = dbo.sales_view.amel_code
AND derivedtbl_2.kala_code = dbo.sales_view.kala_code
GROUP BY derivedtbl_2.amel_code,
derivedtbl_2.kala_code,
derivedtbl_2.kala_name,
derivedtbl_2.kala_unit,
derivedtbl_2.kala_price,
( derivedtbl_2.sum_qty_amani - dbo.sales_view.sum_qty_sales ) *
derivedtbl_2.kala_price
请帮帮我。
答案 0 :(得分:1)
每个子查询或嵌套查询都应具有名称。 例如:
SELECT *
FROM (SELECT * FROM T1 WHERE ID>50) D