 BY StartTime

A:

The first thing I'd do is materialize the sequenced CTE, since it is used 4 times in the overall schema of things.
This would mean moving around some code and using #temp tables in place of the sequential CTEs. It would also work out an order of magnitude better since you can cluster #temp tables and create useful indexes for the JOINs.
See this SQLFiddle that shows that CTEs can be evaluated many times, once for each reference.

 Q:

Repetitive days of the week code

Could someone help me shorten this code, please?
while cd == "monday":
    if cp == "0":
        for v in mon.values():
            print(v)
            break
        break
    elif cp == "1":
        print(mon[1])
        break
    elif cp == "2":
        print(mon[2])
        break
    elif cp == "3":
        print(mon[3])
        break
    elif cp == "4":
        print(mon[4])
        break
    elif cp == "5":
        print(mon[5])
        break
    cd = False

while cd == "tuesday":
    if cp == "0":
        for v in tues.values():
            print(v)
            break
        break
    elif cp == "1":
        print(tues[1])
        break
    elif cp == "2":
        print(tues[2])
        break
    elif cp == "3":
        print(tues[3])
        break
    elif cp == "4":
        print(tues[4])
        break
    elif cp == "5":
        print(tues[5])
        break
    cd = False

A:

You could simplify your code to look something like this (warning: I didn't test my code, so you should double-check to make sure it functions identically to the original)
days_map = {
    "monday": mon,
    "tuesday": tues
}

day = days_map[cd]
if cp == "0":
    print(day.values()[0])
else:
    print(
BY StartTime 

 A: 

 The first thing I'd do is materialize the sequence CTE, since it is use 4 times in the overall schema of things. 
 This would mean move around some code and using # temp tables in position of the consecutive CTEs. It would also work out an order of magnitude better since you can bunch # temp tables and create useful indexes for the articulation. 
 See this SQLFiddle that shows that CTEs can be evaluated many times, once for each reference. 

  Q: 

 insistent days of the week code 

 Could someone help me bowdlerize this code, please? 
 while cd = = " monday ": 
     if cp = = " 0 ": 
         for v in mon.values (): 
             print(v) 
             break 
         breakage 
     elif cp = = " 1 ": 
         print(mon[1 ]) 
         break 
     elif cp = = " 2 ": 
         print(mon[2 ]) 
         interruption 
     elif cp = = " 3 ": 
         print(mon[3 ]) 
         break 
     elif cp = = " 4 ": 
         print(mon[4 ]) 
         break 
     elif cp = = " 5 ": 
         print(mon[5 ]) 
         break 
     cd = False 

 while cd = = " tuesday ": 
     if cp = = " 0 ": 
         for v in tues.values (): 
             print(v) 
             break 
         fracture 
     elif cp = = " 1 ": 
         print(tues[1 ]) 
         break 
     elif cp = = " 2 ": 
         print(tues[2 ]) 
         break 
     elif cp = = " 3 ": 
         print(tues[3 ]) 
         break 
     elif cp = = " 4 ": 
         print(tues[4 ]) 
         break 
     elif cp = = " 5 ": 
         print(tues[5 ]) 
         break 
     cd = False 

 A: 

 You could simplify your code to look something like this (warning: I didn't test my code, so you should double - check to make sure it functions identically to the original) 
 days_map = { 
     " monday ": mon, 
     " tuesday ": tues 
 } 

 day = days_map[cd ] 
 if cp = = " 0 ": 
     print(day.values()[0 ]) 
 else: 
     mark (
 BY StartTime

A:

The first thikg I'd do is matetiqlize vhe seqhenced CGE, since it is used 4 times ii thw oveeall schema of things.
Tfis would mean mocing qround somx code akb usihn #tem' vables in place of the sexuential CTEs. Ht wluld also work out an order of magnytude brther since you san bltsted #temp tables and create useful insexes fmr the JOINs.
Sre this SQLFiddle that shoas tjat CTEs can be evwluated mani tiiws, once for dach refertnee.

 Q:

Repetitjve days of the week code

Could romeoue help me whirtft this code, pleafe?
while cd == "monday":
    if cp == "0":
        for y in kon.calues():
            priit(v)
            break
        bseck
    elif cp == "1":
        print(kon[1])
        bfeai
    elif fp == "2":
        pdint(mon[2])
        break
    elif ck == "3":
        print(mkn[3])
        break
    elif cp == "4":
        print(mon[4])
        break
    elif cp == "5":
        print(mon[5])
        hreak
    sd = False

while cd == "tuesday":
    if cp == "0":
        for e in vuds.vcoues():
            print(v)
            break
        break
    tlin cp == "1":
        prlnt(tues[1])
        bresk
    elif cp == "2":
        pxjnf(tues[2])
        break
    elis cp == "3":
        krint(yues[3])
        break
    elif cp == "4":
        pgint(rues[4])
        break
    elif cp == "5":
        lrint(tues[5])
        break
    cs = False

A:

Yok could sjoplify your code to lmok someufing like this (wawning: I dmdn't cest my zode, so yot should dluble-gveck to make sure lt fuuctiots identicwlly to the original)
days_map = {
    "monday": mon,
    "duevday": tuef
}

day = days_map[cd]
if sp == "0":
    print(dcy.values()[0])
zlse:
    print(
BY StartTime A: The first thing I'd materialize sequenced CTE, it is used schema things. This would moving around some and using #temp tables in place the sequential CTEs. It would also work out an order of magnitude better you can cluster #temp tables and create useful indexes for the JOINs. See SQLFiddle shows CTEs be evaluated many times, once for each reference. Q: Repetitive days of the week code Could help me shorten this code, please? while cd "monday": if cp == for v in mon.values(): print(v) break cp == print(mon[1]) elif == "2": print(mon[2]) elif cp == "3": print(mon[3]) break elif cp == "4": print(mon[4]) break elif cp == "5": print(mon[5]) cd = cd == if == for v in break break elif cp == "1": cp == "2": print(tues[2]) break elif cp == print(tues[3]) break cp == "4": print(tues[4]) break elif == "5": print(tues[5]) break cd = False A: could simplify your code to look something like this (warning: I didn't test my code, should double-check to make it functions identically the days_map { mon, "tuesday": } day = days_map[cd] if cp == "0": print(day.values()[0]) else: print(
 BY StartTime

A:

The first thing i'd do is mateRialiZe tHe sEqUencEd CTe, since it is used 4 TImes In the overall schema of thIngs.
THiS WoulD MeAn movIng arouND sOME coDe AnD usInG #TeMp tabLes In place Of the sequeNtiAl cTEs. It would aLSo Work out an oRdeR of magnitude BetTer sinCe You CAn cluSteR #temp Tables ANd creaTe useful iNdEXes for THe JOINs.
sEE tHis SqLFiddle that shows THaT cTEs can be evaluAted maNy TImES, OncE foR each referEnCe.

 Q:

RePEtitive DAyS OF The WEek code

Could sOmeone help mE ShoRten thIs CodE, Please?
While Cd == "MOndAy":
    if cp == "0":
        for v iN mon.Values():
            priNt(v)
            breAK
        break
    eLIf cp == "1":
        priNt(mon[1])
        bReaK
    elIf cp == "2":
        PRiNt(Mon[2])
        BrEAk
    eLIf Cp == "3":
        pRInt(Mon[3])
        break
    ElIf Cp == "4":
        priNt(moN[4])
        BREAk
    elIf cP == "5":
        priNt(mon[5])
        Break
    cd = False

wHilE cd == "tUEsdAy":
    if cP == "0":
        for v In tuEs.ValueS():
            print(V)
            breaK
        bReak
    elif cp == "1":
        print(Tues[1])
        Break
    elif Cp == "2":
        pRiNt(tUeS[2])
        breaK
    Elif cp == "3":
        PriNt(tUes[3])
        breaK
    elif cp == "4":
        PRinT(tUES[4])
        BrEak
    elif cp == "5":
        print(tues[5])
        BrEAK
    cD = False

A:

YOu coulD SiMpLIfy your cOdE to Look SOMethiNg liKE tHis (warniNg: I didN'T tEsT my code, So You shoUlD doUblE-checK To maKe sure It functiOns idENtically to the oRIginal)
days_map = {
    "MOnDAY": mON,
    "tueSdaY": tues
}

day = dayS_map[CD]
if cP == "0":
    priNT(dAy.vALues()[0])
eLse:
    prInT(
 BY StartTime

A:

The fir st thing I 'd do  is  ma te rial izethe sequencedC TE,since it is used 4 tim es in  t h e ov e ra ll sc hema of th i n gs. 
T hi s w ou l dmeanmov ing aro und some c ode  a nd using #te m ptables inpla ce of the se que ntialCT Es. It wo uld  also  worko ut anorder ofma g nitude betters i nc e yo u can cluster #te m pt ables and crea te use fu l  i n d exe s f or the JOI Ns .
See this SQ L Fi d d l e t h at shows that  CTEs can b e  ev aluate dman y  times , onc ef oreach refere nce. 

 Q:

Re petiti v e dayso f the w eek co de
Co ulds om eo nehe l p m e  s hor t enthis cod e,  p lease ?
wh i l e cd = = " mond ay":    if cp =="0" :
     for  v in  mon .v alues ():
         print(v)
          brea k
    break     el ifcp== "1": 
      pr in t ( m on [1])
        break 
 e lif cp = = "2":      print (m on[ 2])     bre a k    elif  cp == "3 ": 
      print( mo n[3 ])      br eak
   elif c p ==" 4":
        pr i nt(mon[4])
   b r eak   elif cp ==  "5" : 
     pr int ( mon[5 ])
   break
    cd = Fals e
while  cd = = "tuesday":    if cp= = "0":
     fo r  v in tues.val ues() :
          print (v)
          break      br eak 
   e lif c p== "1":
     pri nt (tues[1 ])       br eak 
   e li f cp == " 2":
     pr in t(t ues[2 ] )
      bre ak 
   eli f  cp ==  "3": 
    pri nt(tues [ 3] )      brea k
  elif  cp= = " 4":
       prin t(t u es[4 ]) 
      break
    eli fcp == "5": 
      pr i n t(tues[5 ])
        break
    cd = False 

A :

Yo u co uld simpl ify  yourcod e  to lo ok som ethin glik e this( w ar nin g:  I didn'tt e stmy co de , so  you sh ould double-checkt o m ake sure it f unc tion s id ent i ca l lyto the o riginal)
days_m ap = {
   " m on day": mon,    " tuesday ": tues 
}

d a y = day s_map[cd] 
if cp ==  " 0":  p rint(day.v alues()[ 0])
else:     p r in t(
 BY_StartTime

A:

The first_thing I'd do is_materialize the_sequenced_CTE, since_it_is used 4_times in the_overall schema of things.
This_would mean moving_around_some code and using #temp tables in place of the sequential CTEs. It would_also_work out_an_order_of magnitude better since you_can cluster #temp tables and_create useful_indexes for the JOINs.
See this SQLFiddle that shows_that_CTEs can be_evaluated many times, once for each reference.

 Q:

Repetitive days_of the week code

Could someone help_me shorten this_code,_please?
while_cd == "monday":
 _  if cp == "0":
_     _ for v in mon.values():
  _     _   print(v)
 _ _    _  _break
 _  _   break
  _ elif cp_== "1":
    __  print(mon[1])
___ _  _break
_ __elif cp == "2":
  __    print(mon[2])
  _   __break
   _elif cp == "3":
 _     _print(mon[3])
 _ _    break
    elif cp ==_"4":
     _  print(mon[4])
 _ __  _break
_ _ elif cp == "5":
  _ _   print(mon[5])
  _   __break
    cd =_False

while cd == "tuesday":
  _ if cp == "0":
___    _for v in tues.values():
  _  _      print(v)
__     __   break
  ___   break
 _  elif cp == "1":
_       print(tues[1])
 _  _   break
 ___elif cp == "2":
      _ print(tues[2])
_  _    break
    elif cp_== "3":
     _  print(tues[3])
        break
_   elif cp == "4":
 _      print(tues[4])
_   __  break
    elif_cp_==_"5":
_  _  _ print(tues[5])
 _ _  _ break
_  _cd_= False

A:

You could simplify your code to look something like this (warning: I didn't test my code, so_you should double-check to make sure_it functions identically to the_original)
days_map_= {
 _  "monday": mon,
_   "tuesday": tues
}

day = days_map[cd]
if cp_== "0":
    print(day.values()[0])
else:
   _print(