Need help for condition

Hello All
  I have an order with the time 08/03/2015 7:30 08/03/2015 10:30
  I have availability with the time 08/03/2015 07:00:00 to 08/03/2015 19:30:00
  Here the availability falls for 3 hours only
  My requirement is that For order if availability< 4hours i don't want to show employee.
  How to apply the condition.

Waiting for valuable replies

July 24th, 2015 1:16pm

Please post your table structure, some input and desired output. Your current problem's description is not enough.
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 1:23pm

Hi,

  Thank you for your reply. We are getting the data from no of tables. Because of that I am unable to post the structure. I need to know how to write the condition. Please guide me on this.

July 24th, 2015 1:27pm

You should make an effort to provide a better description of the problem. 
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 1:34pm

According to your description : How you want to measure 4 hours ? if from the current time then compare it with difference between getdate() and ordertime < 4 then .... 
July 24th, 2015 5:10pm

  Thank you for your reply. We are getting the data from no of tables. Because of that I am unable to post the structure. I need to know how to write the condition. Please guide me on this.

And we need to know your tables to help you accurately. From what you said, well,

SELECT *
FROM   Employees
WHERE  (SELECT SUM(datediff(minute, O.fromtime, O.totime))
        FROM   Orders O
        WHERE  O.EmployeeID = E.EmployeeID
          AND  O.fromtime >= E.fromtime
          AND  O.totime  <= E.totime) >= 240

But if this is anywhere remotely close to your tables, I would be highly surprised.

For this type of problem, you help yourself immensel if you post:

1) CREATE TABLE statements for your tables, preferrably simplified for the pertinent parts of the problem.
2) INSERT statements with sample data.
3) The desired result given the sample.
4) A short description of the business rules.
5) Which version of SQL Server.

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 6:31pm

Hi All,

    Thanks for suggestions and I will follow the suggestions given by all.

July 24th, 2015 11:03pm

Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI-ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. You failed! We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI-ISO Standard SQL. 
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 8:38am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics