• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Becoming old and senile

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Becoming old and senile

    I've revisited some SQL I wrote about 5 or more years ago. It makes no sense to me at all now.

    Code:
    select x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
    	  from
    
    	 (Select linkID, html, url, title, description, contactEmail, reciprocalLinkUrl, status, lastChecked, missingCount, pageRank, hits, lastHit, rating, votes, averageRating, commentCount, created, updated,
    		substr(' ' || l.description || ' ' || l.title || ' ',seq,
    		CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq) as words
    	from SEQUENCE
    	inner join vwVisibleLinks l	
    	where
    	 seq <= length(' ' || l.description || ' ' || l.title || ' ') and
    	 substr(' ' || l.description || ' ' || l.title || ' ', seq - 1, 1) = ' ' and
    	 CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq > 0) as x
    	 inner join
    	 (Select substr(@searchTerm,seq,
    		CharIndex(' ' , @searchTerm , seq) - seq) as keywords
    	from SEQUENCE
    	where
    	 seq <= length(@searchTerm) and
    	 substr(@searchTerm, seq - 1, 1) = ' ' and
    	 CharIndex(' ' ,@searchTerm, seq) - seq > 0) as y
    	 on x.words like y.keywords
         inner join linkCategories lc
         on lc.linkID = x.linkID
         inner join categories c
         on lc.categoryID = c.categoryID
         where c.lft between (select lft from categories where categoryID = @categoryID) and (select rgt from categories where categoryID = @categoryID)
         group by x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
         order by count(x.linkid) desc
    NickFitz, over to you....




    I'm not cut out for this anymore. Looking at management roles now.


    #2
    That's SKA? You work for AtW?

    Comment


      #3
      Feck me, I can still understand that.

      It never leaves you.
      What happens in General, stays in General.
      You know what they say about assumptions!

      Comment


        #4
        Originally posted by DimPrawn View Post
        I've revisited some SQL I wrote about 5 or more years ago. It makes no sense to me at all now.

        Code:
        select x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
        	  from
        
        	 (Select linkID, html, url, title, description, contactEmail, reciprocalLinkUrl, status, lastChecked, missingCount, pageRank, hits, lastHit, rating, votes, averageRating, commentCount, created, updated,
        		substr(' ' || l.description || ' ' || l.title || ' ',seq,
        		CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq) as words
        	from SEQUENCE
        	inner join vwVisibleLinks l	
        	where
        	 seq <= length(' ' || l.description || ' ' || l.title || ' ') and
        	 substr(' ' || l.description || ' ' || l.title || ' ', seq - 1, 1) = ' ' and
        	 CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq > 0) as x
        	 inner join
        	 (Select substr(@searchTerm,seq,
        		CharIndex(' ' , @searchTerm , seq) - seq) as keywords
        	from SEQUENCE
        	where
        	 seq <= length(@searchTerm) and
        	 substr(@searchTerm, seq - 1, 1) = ' ' and
        	 CharIndex(' ' ,@searchTerm, seq) - seq > 0) as y
        	 on x.words like y.keywords
             inner join linkCategories lc
             on lc.linkID = x.linkID
             inner join categories c
             on lc.categoryID = c.categoryID
             where c.lft between (select lft from categories where categoryID = @categoryID) and (select rgt from categories where categoryID = @categoryID)
             group by x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
             order by count(x.linkid) desc
        NickFitz, over to you....




        I'm not cut out for this anymore. Looking at management roles now.

        Reading that tulipe query you clearly weren't cut out for it in the first place
        Coffee's for closers

        Comment


          #5
          the first system I worked on professionally... used to dump things as ascii but in hex and reversed. so believe it or not i was quite good at reading large amounts of hex backwards and being able to tell what it said...

          i saw some of this about 6 months ago and could make little bits out but not the fluency i once had

          ah them was the days

          Comment


            #6
            I actually...... doh, forgot what I was going to say. Nevermind.
            'CUK forum personality of 2011 - Winner - Yes really!!!!

            Comment


              #7
              Looks like it made no sense when you wrote it

              Comment


                #8
                One of the first things I learnt is that most code one writes will be uncomprehensible to everyone(includng the author) after 6 months. So I try to make sure all the code I write can be understoiod by anyone with appropriate comments.

                Sas thinks its easy - which means he is not clever enough to do it.

                Comment


                  #9
                  Originally posted by BrilloPad View Post
                  Sas thinks its easy - which means he is not clever enough to do it.
                  I don't think coding is easy - I did it for the first 10 years of my career after all.
                  In fact it's too much like hard work, slaving away on the computer - far better to do modelling which involves checking assumptions on the data, data cleaning, data shaping, fitting a model, doing some checks and presenting your results. And quite often you'll have a programmer assigned to do the dull data munging bits, so your main job is to use your experience to think of the appropriate model to suit the data. Quite often you use the same model again and again. Piece of piss and it pays more.
                  Hard Brexit now!
                  #prayfornodeal

                  Comment


                    #10
                    Originally posted by Spacecadet View Post
                    Reading that tulipe query you clearly weren't cut out for it in the first place
                    20+ years later, and £1m later, I sort of agree with you.

                    Comment

                    Working...
                    X