Help Help New Qith SQL

Sep 30, 2005

Hi

I am new to SQL and I have a unique need

I have 2 DB on the same machine DB 1 is called Test1 and DB 2 is called Test2

I want to be able to write one query to compare 2 tables from each of the Databases.

I wrote the first query ie,
use Test
SELECT Unit_Identifier,Piece_Id,Piece_Count
FROM Piece_Unit
where Version_Date = '01/01/2005' order BY Piece_Id

and I get the result from the Piece_unit Table

I wrote another query ie
use Test1
SELECT Piece_Id,PieceName,Inserts
from PalletDetails
WHERE VersionDate = '01/01/2005' ORDER BY Piece_Id


and I get the result from the PalletDetails table


The piece_id of both Tables are same value

I want to combine both queries to a single query and ONLY list the difference from both Tables in reference to the piece_id ( Only list piece_id) that exist on either table only


Thanks

View 1 Replies


ADVERTISEMENT

Need Help Qith SQL Query - How To Group Sales?

Apr 13, 2004

Hi,

I currently have a table whose structure is as follows:

CREATE TABLE [tblSales] (
[OrderID] [int]
[SaleDate] [smalldatetime] ,
[ProductCode] [nvarchar] (255) ,
[QtySold] [float] ,
[UnitPrice] [float] ,
[Discount] [float] ,
[GrossSaleAmount] NULL ,
[NetSaleAmount] [float]
)

The GrossSaleAmount and NetSaleAmount are calculated fields. But for this post, kindly ignore why I am storing calcuated fields...


QUESTION:
What I want to do is to populate another table (the DDL of which is give below) from tblSales in such a manner that the TOTAL sales from each product for each available date is grouped/summed together.

[blue]CREATE TABLE [tbl_Product_Grouped_Sales] (
[SaleDate] [smalldatetime] ,
[ProductCode] [nvarchar] (255) ,
[TotalQtySold] [float] ,
[NetSaleAmt] [float]
)



Thanks in advance for your help.

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved