0

I have 2 query. first is

SELECT CASE WHEN WEEKDAY('2017-03-01') <= 5 THEN 5 -  
WEEKDAY('2017-03-01') ELSE 0 END + CASE WHEN WEEKDAY('2017-03-03') <= 5 THEN
WEEKDAY('2017-03-03') + 1 ELSE 5 END + (DATEDIFF('2017-03-03', 
'2017-03-01') + 1 - (7 - WEEKDAY('2017-03-01')) - (WEEKDAY('2017-03-03') + 
1)) DIV 7 * 5 AS w_d 

an output of that query is

w_k
 3

and the 2nd one is

  SELECT count(*) FROM attendence WHERE eid=1 and login < ('2017-03-03' + interval 1 day ) AND login >= '2017-03-01' .

an output of that query count(*)

3

and I want to subtract query1 - 2.

1 Answer 1

1

Try this

    Select (
    (SELECT CASE WHEN WEEKDAY('2017-03-01') <= 5 THEN 5 - WEEKDAY('2017-03-01') ELSE 0 END + CASE WHEN WEEKDAY('2017-03-03') <= 5 THEN WEEKDAY('2017-03-03') + 1 ELSE 5 END + (DATEDIFF('2017-03-03', '2017-03-01') + 1 - (7 - WEEKDAY('2017-03-01')) - (WEEKDAY('2017-03-03') + 1)) DIV 7 * 5) - 
(SELECT count() FROM attendence WHERE eid=1 and login < ('2017-03-03' + interval 1 day ) AND login >= '2017-03-01')) AS w_d
Sign up to request clarification or add additional context in comments.

5 Comments

@Mayur Did this Solve your issue?
Hi sir, is it possible, combined or join above 2 query and show a different output of both of them? and similar column of both tables is [ id ]. if possible then can u give me hint about the query. Thank You in Advanced.
Could you explain what you need with output so that i will directly got your point.
I have 4 unrelated query and I want to combine this and get output in tabular format.plz, give me hint for that.
I think you want to Union . for this please see below link dev.mysql.com/doc/refman/5.7/en/union.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.