Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
avols143
Starting Member
1 Post |
Posted - 2011-01-26 : 14:51:50
|
| Hi,I want to find the dates which have a date plus with in 2 days after this date. I mean group by 3 days each even the date i missing between two days. Actualy I want to find the start date where the employ was missing on job.Basic concept is employes have allowed to use 10 personal leaves of a year. Each leave can be use for maximum 3 days. If employ did not come on the job for one day or two days or three days, it shoul be count as ONE personal leave. And If employ is missing at job for four or five days, it should be count as 2 personal leaves.seq date------------------------------1 01.01.102 05.01.10 3 06.01.104 10.01.105 12.01.106 13.01.107 14.01.108 15.01.109 16.01.1010 18.01.1011 19.01.1012 20.01.1013 21.01.1014 23.01.1015 26.01.1016 27.01.1017 29.01.1018 31.01.10 The result should be (Don't use Pl/Sql)seq date------------------------------1 01.01.102 05.01.103 10.01.104 13.01.105 16.01.106 19.01.107 23.01.108 26.01.109 29.01.10After finding these days I want to select the starting date of 5th personal leave. (which is 16.01.10). I am not a expert of using SQL, but I think it could be possible with using partitioning a table on the givin reslult and further partition the reslut on rownum() as rn and the using case statement where rn = 5.You people can have another best idea to do this.Thanks |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-01-26 : 16:20:03
|
| Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. If you know how, follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats, not the local dialect you posted. Code should be in Standard SQL as much as possible and not local dialect. Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it. If you want to learn how to ask a question on a Newsgroup, look at: http://www.catb.org/~esr/faqs/smart-questions.htmlDon't worry aobut us using PL/SQL -- This not an Oracle forum. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|
|
|