home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,238 of 19,505   
   Erland Sommarskog to M.G.   
   Re: to show full set of two tables   
   26 Jul 16 11:51:23   
   
   From: esquel@sommarskog.se   
      
   M.G. (michael@gurfinkel.us) writes:   
   > There is an assignment schedule where several entities are assigned on a   
   > daily basis, in ID/DATE simple fashion.   
   >   
   > I need to report all IDS per every date in the work dates calendar,   
   > including instances where no assignment exists:   
   >...   
   >   
   > It works OK, but I suspect my solution could (and should) be simplified.   
   > Any ideas?   
      
   So two things strikes me as odd here.   
      
   1) If the result set is supposed to show whether there is an assignment for   
   a certain ID on a certain date, I would expect three columns: date, id and a   
   yes/no column. Now there are multiple rows with NULL on the same date if   
   there is no assignment at all.   
      
   2) I would expect there to be a table to hold the IDs as such. In that case   
   the SELECT DISTINCT in the CTE could be replace with a straight SELECT   
   from that table.   
      
   Else, this is the typical pattern for this type of query.   
      
      
   --   
   Erland Sommarskog, Stockholm, esquel@sommarskog.se   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca