• 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!

Calling all hardcore SQL experts! A challenge

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

    #21
    Originally posted by _V_ View Post
    Thanks for the advice folks. Using a sequence table to join on to expand the date range I managed to get the whole calculation done in a single SELECT (look no loops required!!!).

    Lovely stuff this SQLite!



    PS. The permies haven't got a clue how this works. Which is nice.
    Well done!

    Although I would have used an outer join rather than the NOT EXISTS but given the size of the data sets you're querying I doubt that there would be that big an impact on performance
    Coffee's for closers

    Comment


      #22
      Originally posted by Spacecadet View Post
      Well done!

      Although I would have used an outer join rather than the NOT EXISTS but given the size of the data sets you're querying I doubt that there would be that big an impact on performance
      That depends on the plan - which would depend on the statistics and indexes and all sorts.....
      McCoy: "Medical men are trained in logic."
      Spock: "Trained? Judging from you, I would have guessed it was trial and error."

      Comment


        #23
        Originally posted by Bob Dalek View Post
        Looping?
        SQL was originally defined as a declarative language; declarative languages don't have loops. Loops lead to side effects, which are a Bad Thing.

        It always annoys me when people refer to XSLT as having loops (which it doesn't).

        Comment

        Working...
        X