TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akhter HUssain
720
1.3k
102.1k
Report req Sum of Sales order qty and daily produce quantity
Jul 31 2019 3:52 AM
i want report in which sum of sales order qty of all (open) order and day wise produce qty require in a report here is my data and expected result...
CREATE
TABLE
#SalesOrder (OrderNo
INT
,Order_Ref_No
VARCHAR
(50), Order_date
date
,Status
Varchar
(50));
CREATE
TABLE
#OrderDetail (IDOD
INT
,OrderNO
int
,CodeItem
int
,orderqty
int
);
CREATE
TABLE
#Sections (SecID
INT
,Secnam
VARCHAR
(50));
CREATE
TABLE
#ItemMasterFile(CodeItem
INT
,Descriptionitem
VARCHAR
(50),SecID
INT
,weight
int
);
CREATE
TABLE
#Probale(BID
INT
,CodeItem
INT
,prdQTY
INT
,Orderno
int
,weight
int
,Entrydate DATETIME,DelID
int
);
INSERT
INTO
#Sections
VALUES
(1,
'HR'
),(2,
'Baby'
),(3,
'Ladies'
),(4,
'Mix Rammage'
),(5,
'T-Shirst'
),(6,
'Scrap'
),(7,
'Scrit'
),(8,
'Men'
),(9,
'HHR'
),(10,
'Sports'
),(11,
'm-HR'
),(12,
'M-Baby'
),(13,
'M-Ladies'
),(14,
'M-Mix Rammage'
),(15,
'm--Shirst'
),(16,
'M-Scrap'
),(17,
'M-Scrit'
),(18,
'M-Men'
),(19,
'M-HHR'
),(20,
'M-Sports'
);
INSERT
INTO
#ItemMasterFile
VALUES
(1,
'A'
,1,100)
, (2,
'B'
,2,100)
, (3,
'C'
,3,100)
, (4,
'D'
,4,100)
, (5,
'e'
,5,100)
, (6,
'f'
,6,100)
, (7,
'g'
,4,100)
, (8,
'h'
,4,100)
, (9,
'K'
,2,100)
, (10,
'L'
,4,100)
, (11,
'M'
,2,100);
INSERT
INTO
#Probale
VALUES
(1,1,1,001,100,
'01-06-2019'
,
null
)
, (2,3,1,001,200,
'02-06-2019'
,
null
)
, (3,11,1,002,200,
'03-06-2019'
,
null
)
, (4,10,1,002,200,
'08-06-2019'
,
null
)
, (4,1,1,003,200,
'08-06-2019'
,
null
)
, (4,3,1,003,200,
'08-06-2019'
,
null
);
INSERT
INTO
#SalesOrder
VALUES
(001,
'A_01'
,
'01-05-2019'
,
'Open'
)
, (002,
'B_01'
,
'01-05-2019'
,
'Open'
)
, (003,
'C_01'
,
'01-05-2019'
,
'Open'
);
INSERT
INTO
#OrderDetail
VALUES
(1,001,1,5)
, (2,001,2,3)
, (3,001,3,2)
, (4,002,10,4)
, (5,002,11,3)
, (6,002,3,2)
, (7,003,1,4)
, (8,003,2,3)
, (9,003,3,2);
here is my expected result...
Reply
Answers (
9
)
Add to one table mssql
join query with default value, if no match