DELETE from `queries` where `ID`=530;
DELETE from `queries` where `ID`=120;
DELETE from `queries` where `ID`=110;
DELETE from `queries` where `ID`=100;

INSERT INTO `queries` (`ID`, `Qseq`,`Desc`, `QSQL`, `External`) VALUES (100, 100, 'Iteration Hours', 'select concat( initials,'' - '' ,Friendly_Name) as User ,IF(Done=1,''Yes'',''No'') as Done , sum( Expected_Hours) as ''Est. hrs'', sum(Actual_Hours) as ''Act. hrs'' from story left join iteration on story.Iteration_ID = iteration.ID, task left JOIN user on task.User_ID = user.ID where story.Iteration_ID = 1 and task.Story_AID = story.AID group by User_ID, Done, Iteration_ID ',2);
INSERT INTO `queries` (`ID`, `Qseq`,`Desc`, `QSQL`, `External`) VALUES (110, 110, 'My Tasks', 'select concat( initials,'' - '' ,Friendly_Name) as User, story.ID as ''Story #'' ,task.Desc as Task,IF(Done=0,''-'',IF(Done=1,''In Progress'',''Done'')) as Status, Expected_Hours as ''Est. hrs'', Actual_Hours as ''Act. hrs'' from story left join iteration on story.Iteration_ID = iteration.ID, task left JOIN user on task.User_ID = user.ID where story.Iteration_ID = {Iteration} and User_ID = {User} and task.Story_AID = story.AID order by story.Iteration_Rank, story.ID, Done',2);
INSERT INTO `queries` (`ID`, `Qseq`,`Desc`, `QSQL`, `External`) VALUES (120, 120, 'Iteration Tasks', 'select concat( initials," - " ,Friendly_Name) as User, story.ID as ''Story #'' ,task.Desc  as Task,IF(Done=0,''-'',IF(Done=1,''In Progress'',''Done'')) as Status,  Expected_Hours as ''Est. hrs'', Actual_Hours as ''Act. hrs'' from story left join iteration on story.Iteration_ID = iteration.ID, task  left JOIN user on task.User_ID = user.ID  where story.Iteration_ID = {Iteration} and task.Story_AID = story.AID order by story.Iteration_Rank, story.ID, User_ID,  Done',2);
INSERT INTO `queries` (`ID`, `Qseq`,`Desc`, `QSQL`, `External`) VALUES (530, 530, 'Uploaded Files', 'select concat(''<a href=story_List.php?searchstring=%23'',story.ID,''&PID='',story.Project_ID,''&Type=search>#'',story.ID,''</a>'') as ''Story'', story.Summary as ''Summary'', upload.Desc as ''File'' , CONCAT(''<a href=upload/'',HEX(upload.Name),''.'',convert(upload.Type using utf8),''>Link</a>'')as ''Link'' from story inner join `upload` on upload.AID=story.AID  where story.Project_ID=1 order by upload.Desc', 2);
update dbver set CurrVer = 1.17 where dbver.ID=1;