Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Combine two SQL queries into 1 with UNION

$
0
0

Hi,

Im trying to combine 2 sql queries into 1 possibly with a union but Im unsure.... I appreciate that a union should have the same amount of columns per query but on my occaison there isnt as they are 2 completely different queries but link with the TraceableBinItem.TraceableItemID.

Could anyone suggest where I am going wrong please - below are my sql statements without the union

SQL
SELECTStockItem.Code,TraceableItem.IdentificationNo,TraceableBinItem.BinName,TraceableBinItem.TraceableItemID,TraceableBinItem.GoodsInQuantity-TraceableBinItem.GoodsOutQuantityASQtyInStock,StockItem.DateTimeCreatedas'BOOKED IN'FROMStockItemINNERJOINTraceableItemONStockItem.ItemID=TraceableItem.StockItemIDINNERJOINTraceableBinItemONTraceableItem.TraceableItemID=TraceableBinItem.TraceableItemIDWHERETraceableBinItem....

Viewing all articles
Browse latest Browse all 4871

Trending Articles