Query in sqlserver

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NareshN
    New Member
    • Aug 2010
    • 45

    Query in sqlserver

    Hi All,

    i have this table data based on this i need to display reports.

    TimeId EmpNo Date TimeIn TimeOut TotalTime
    1 100 8/1/2010 17:00 2:00 9 hours
    2 100 8/2/2010 17:00 2:00 9 hours
    3 100 8/3/2010 Off Off Off
    so on upto 4 weeks data and for all the remaining employees

    Based on this data i need to find the percentage of employees who are getting off in the same day.


    Out of 100 employees 50 employees may get off in same day say saturday so 50% of the employees are getting off in same day.It can be any day.
    I need to find for last 4 weeks,3 weeks,2 weeks.

    This week 50 may get on saturday,anothe r 25 may get on sunday still 75% of the employee's are getting off in same day.

    Result for last 4 weeks,3 weeks and 2 weeks
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Out of 100 employees 50 employees may get off in same day
    Wow! Can you get me a job there?
    You really need to make some attempt at your homework before help is forthcoming.

    Break the question down into smaller parts and think how you wish the data to be portrayed.

    You will probably make use of COUNT, BETWEEN and the equation for percentage which is total_off/total_empl * 100

    Comment

    • Oralloy
      Recognized Expert Contributor
      • Jun 2010
      • 988

      #3
      @NareshN,

      Code_Green is right. You need to analyze your problem a bit and develop your requirements.

      Not just the broad-brush output, but in detail, what is the meaning of each item that you generate.

      Once you do that, then the algorithm to compute the values usually becomes obvious.

      Also, think of the strange cases that might happen. Perhaps somebody works late Thursday, leaves Friday, comes back Friday and leaves early again on that same day. Is that two people leaving on Friday, or only one?

      Anyway - think about what you need, write clear requirements, and we can help you with the details.

      Cheers!
      Oralloy

      @Code_Green, I'm not trying to steal your thunder - just trying to clarify what you wrote in words that I understand.

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        @Code_Green, I'm not trying to steal your thunder - just trying to clarify what you wrote in words that I understand
        Thats OK. But I'm first in line for that job.

        Comment

        • Oralloy
          Recognized Expert Contributor
          • Jun 2010
          • 988

          #5
          @Code_Green, I'm not trying to steal your thunder - just trying to clarify what you wrote in words that I understand
          Thats OK. But I'm first in line for that job.
          All yours buddy . . . all yours.

          Comment

          Working...