last day (14 days later) » 

9:03 AM
 
N K
hi JOE
 
Ok
Hi NK
 
N K
see
i executed your query
 
Ok
 
N K
but getting error as Msg 208, Level 16, State 0, Line 1
Invalid object name '#temp'.
 
9:04 AM
Have you added CREATE TABLE #temp statement?
Post here you SP code
 
N K
yup
ALTER PROCEDURE GET_RECORDS_FORDATE
@From_date Datetime,
@To_date Datetime

AS
BEGIN
CREATE TABLE #temp(
date datetime, Total int, Inward int, First_Level_Transfer int,
Data_Entry_Transfer int,
Second_Level_Transfer int, Outward_Transfer int,
Closed int, Communication_Transfer int
)

INSERT INTO #temp
(date, Total, Inward, First_Level_Transfer,
Data_Entry_Transfer,
Second_Level_Transfer, Outward_Transfer,
Closed, Communication_Transfer)
SELECT
doc_date, COUNT(*),
SUM(
CASE
WHEN status_flag = '6' THEN 1 ELSE 0
 
select * from #temp must be in the SP
 
N K
ok
after END ??
 
a temporary table (starts with #) yo can see in the session only
before the last end
the end close the begin statement of SP
 
N K
yes
let me check
first row is pulling wrong data
see
second one is correct
total is 6
but
if we do total it is coming as 4
are u thier ?
 
9:11 AM
mmm
 
N K
see
this is actual query
select count(*) tot_count,'Total' stage from inward_doc_tracking_hdr where doc_date >=convert(datetime,'24/05/2016',103)
union all
select count(*) tot_count,'Inward' stage from inward_doc_tracking_hdr where doc_date >=convert(datetime,'24/05/2016',103) and status_flag in ('6')
union all
select count(*) tot_count,'1st Level Transfer' stage from inward_doc_tracking_hdr where doc_date >=convert(datetime,'24/05/2016',103)
and status_flag in ('4','26','24')
union all
select count(*) tot_count,'Data Entry Transfer' stage from inward_doc_tracking_hdr where doc_date >=convert(datetime,'24/05/2
which i am adding in SP
 
your
status
I've used 6, 4,26, 24, 15, 20, 17, 21, 18, 5, 16
all are?
status = 6?
 
N K
?
 
may be it?
you have:
/*union all
select count(*) tot_count,'Return to Creator' stage from inward_doc_tracking_hdr where doc_date >=convert(datetime,'24/05/2016',103)
and status_flag='6'*/
commented
 
N K
yes
its commented
 
9:13 AM
this condition returns 2
 
N K
og
ohh
do u have added it
?
 
because in total you have 6 not bounded on status flag
may be
 
N K
please check and remove that
 
Hello everyone :)
 
9:15 AM
after the last sum and before the from clause
SUM(
CASE
WHEN status_flag='6' THEN 1 ELSE 0
END)
and add a new column in your #temp table
 
N K
i dont want for return to creator
hi PKIRBY
how are you
 
so your total must be 4?
 
N K
yup
 
in your main query add this: status_flag <> '6'
in and with existing where condition
 
N K
confused
can u updated it and show
@PKirby: i will come back to you in few mins
 
9:17 AM
Good thanks, just going through the comments to figure out whats going on. Seems like you busy sorting it out.
No problem
 
N K
it is something what we did
a week back
@PKirby i think you got the idea what i want
@JoeTaras: please update the answer and let me know
 
:O
ok
 
Yeah last time we had a chat we were busy creating a SP to do counts?
 
done
 
N K
yes
its similar what I want here also
 
9:19 AM
ok
so we are over?
 
N K
let me check
 
ok
 
N K
it still giving me 6
and i want Sr No also
 
mmmm
dear, if you talk about total
how can you have a single sr_no?
 
N K
sr_no means, 1,2,3
here are two records
 
9:24 AM
have you only that table?
 
N K
so I want sr_no as 1, 2
 
in this table:
for a sr_no number 12345
how many record can you have?
inward_doc_tracking_hdr
 
N K
how many means ?
it can be as many depending upon the records
in the table
 
have you a little result set of your table?
filtered by sr_no?
post it, please
in your question
so the total column
must be
the number of rows related to the same sr_no?
add this
and if this is the scenario, have you a table where you listed all sr_no? Parent of inward_doc_tracking_hdr
 
N K
9:39 AM
hey
no issue
i got that clear
u can update your answer
yours is correct
 
ok
please accept my answer
and if you want upvote it
 

last day (14 days later) »