Click here to Skip to main content
16,006,749 members
Home / Discussions / Database
   

Database

 
Questionselect random rows Pin
swjam30-Sep-08 15:19
swjam30-Sep-08 15:19 
Answerupdate... Pin
swjam30-Sep-08 15:43
swjam30-Sep-08 15:43 
AnswerRe: select random rows Pin
J4amieC30-Sep-08 22:36
J4amieC30-Sep-08 22:36 
QuestionSetup and Deployment of Database Project without server Pin
sawerr30-Sep-08 13:23
sawerr30-Sep-08 13:23 
AnswerRe: Setup and Deployment of Database Project without server Pin
nelsonpaixao30-Sep-08 14:20
nelsonpaixao30-Sep-08 14:20 
AnswerRe: Setup and Deployment of Database Project without server Pin
Mycroft Holmes30-Sep-08 23:20
professionalMycroft Holmes30-Sep-08 23:20 
AnswerRe: Setup and Deployment of Database Project without server Pin
Wendelius1-Oct-08 4:20
mentorWendelius1-Oct-08 4:20 
QuestionSelect Top 1 using join Pin
Lash2030-Sep-08 10:25
Lash2030-Sep-08 10:25 
I understand for performance reasons, that the section in bold can be rewritten using a join, can anyone help me with the syntax. I am trying to select the most recent employee record where effective_date <= payperiod_enddate.

Thanks

select
t1.department,
t2.status,
t3.date_key as paycheck_date_key,
t4.date_key as start_date_key,
t5.date_key as end_date_key,
(select top 1 employee_key from d_employee where (employee_id = EEID and employee_number = EmpNum) and
(CAST(FLOOR( CAST( effective_date as float ) )as datetime) <= PeriodEndDate) order by effective_date desc) as employee_key
,
t6.payment_type_key as payment_type_key,
from tblDetail t1
inner join tblHeader t2
left join d_date t3 on isnull(t2.PayDate, '01/01/1900') = t3.the_date
left join d_date t4 on isnull(t2.PeriodStartDate, '01/01/1900') = t4.the_date
left join d_date t5 on isnull(t2.PeriodEndDate, '01/01/1900') = t5.the_date
on t1.checkID = t2.checkID
left join d_PAYMENT_TYPE t6 on isnull(t1.PehEarnCode, '-999') = t6.payment_type_code
QuestionHow can I select all but with a distinct column and top of another ordered column Pin
fly90430-Sep-08 5:40
fly90430-Sep-08 5:40 
AnswerRe: How can I select all but with a distinct column and top of another ordered column Pin
J4amieC30-Sep-08 5:50
J4amieC30-Sep-08 5:50 
GeneralRe: How can I select all but with a distinct column and top of another ordered column Pin
fly90430-Sep-08 6:05
fly90430-Sep-08 6:05 
AnswerRe: How can I select all but with a distinct column and top of another ordered column Pin
Blue_Boy30-Sep-08 8:33
Blue_Boy30-Sep-08 8:33 
GeneralRe: How can I select all but with a distinct column and top of another ordered column Pin
J4amieC30-Sep-08 22:35
J4amieC30-Sep-08 22:35 
Generaldesigning a software for a typical office Pin
niconicx30-Sep-08 2:36
niconicx30-Sep-08 2:36 
GeneralRe: designing a software for a typical office Pin
Mycroft Holmes30-Sep-08 23:23
professionalMycroft Holmes30-Sep-08 23:23 
QuestionGet All Database Names???? Pin
astrovirgin30-Sep-08 0:11
astrovirgin30-Sep-08 0:11 
AnswerRe: Get All Database Names???? Pin
Mycroft Holmes30-Sep-08 0:22
professionalMycroft Holmes30-Sep-08 0:22 
AnswerRe: Get All Database Names???? Pin
Wendelius30-Sep-08 3:19
mentorWendelius30-Sep-08 3:19 
Questionmultiple combination searching query Pin
dream_liner_7e729-Sep-08 23:11
dream_liner_7e729-Sep-08 23:11 
AnswerRe: multiple combination searching query Pin
ChandraRam29-Sep-08 23:29
ChandraRam29-Sep-08 23:29 
QuestionRe: multiple combination searching query Pin
dream_liner_7e730-Sep-08 0:03
dream_liner_7e730-Sep-08 0:03 
AnswerRe: multiple combination searching query Pin
ChandraRam30-Sep-08 1:24
ChandraRam30-Sep-08 1:24 
GeneralRe: multiple combination searching query Pin
dream_liner_7e75-Oct-08 22:01
dream_liner_7e75-Oct-08 22:01 
AnswerRe: multiple combination searching query Pin
Wendelius30-Sep-08 3:14
mentorWendelius30-Sep-08 3:14 
Questionconfigure filestream for sqlserver2008 Pin
Pankaj Saha29-Sep-08 21:47
Pankaj Saha29-Sep-08 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.