August 22, 2011 at 7:21 am
CREATE TABLE [dbo].[A](
[ID] [float] NULL,
[MATERIAL ] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[QTY] [float] NULL,
[RATE] [float] NULL,
[BASIC] [float] NULL,
[EX_DUTY] [float] NULL,
[SALE_TAX] [float] NULL,
[TOTAL_AMT] [float] NULL,
) ON [PRIMARY]
CREATE TABLE [dbo].(
[ID] [float] NULL,
[MATERIAL ] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[QTY] [float] NULL,
[RATE] [float] NULL,
[BASIC] [float] NULL,
[EX_DUTY] [float] NULL,
[SALE_TAX] [float] NULL,
[TOTAL_AMT] [float] NULL,
) ON [PRIMARY]
INSERT INTO A VALUES(1,'T1', 100, 2.0, 200, 3, 5, 208)
INSERT INTO A VALUES(1,'T1', 100, 2.0, 200, 3, 5, 208)
INSERT INTO A VALUES(1,'T2', 100, 3.5, 250, 25, 5, 600)
INSERT INTO B VALUES(1,'T1', 200, 2.5, 500, 6, 10, 516)
INSERT INTO B VALUES(1,'T2', 100, 3.5, 250, 25, 5, 600)
I WANT TO DISPLAY THE RESULTS IN THE FOLLOWING WAY
1 T1 100 2.0 200 3 5 208
1 T1 100 2.0 200 3 5 208
1 T1 200 2.5 500 6 10 516
DIFF 1 T1 0 0.5 100 0 0 100
August 22, 2011 at 8:21 am
If you can explain what the "results" are we can probably help. Nice job providing the ddl and sample data but it is totally unclear what you want out.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply