NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 5 6 7 8 9 … 93 Next »
Another SQL question

 
  • 0 Vote(s) - 0 Average
Another SQL question
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,904
Threads: 955
Joined: May 2006
#11
2012-06-24, 06:03 PM
ACTCMS Wrote:Very elegant Martin Smile unfortunately, there seems to be no guarantee that the EPG_EVENT oid is in the same sequence as start_time (at least not on my system)

Alex

Thanks, I was going to mention that the XMLTV source had to actually be in date order for that to work and for OTA EPG it might not but I didn't have any source to confirm.

Martin
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,904
Threads: 955
Joined: May 2006
#12
2012-06-24, 07:43 PM
Maybe this

Code:
select * from epg_event,
(select min(start_time) as start_time,channel_oid
from EPG_EVENT
where start_time > datetime('now')
group by channel_oid) next
where epg_event.start_time = next.start_time
and epg_event.channel_oid = next.channel_oid

Martin
odin
Offline

Member

Posts: 105
Threads: 12
Joined: Oct 2011
#13
2012-06-24, 08:00 PM
mvallevand Wrote:Maybe this

Code:
select * from epg_event,
(select min(start_time) as start_time,channel_oid
from EPG_EVENT
where start_time > datetime('now')
group by channel_oid) next
where epg_event.start_time = next.start_time
and epg_event.channel_oid = next.channel_oid

Martin

that only shows the 'next' on my system.
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#14
2012-06-24, 08:08 PM
mvallevand Wrote:Maybe this
Martin, I think you might have missed my post at #10 of this thread. It took a while to type as I was doing it between helping my wife with some chores and I think you missed it as you responded to Alex's post.

Cheers,
Brian
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,904
Threads: 955
Joined: May 2006
#15
2012-06-24, 08:30 PM
odin Wrote:that only shows the 'next' on my system.

Wasn't that what bgowland asked for?

Martin
bgowland
Offline

Posting Freak

West Yorkshire, UK
Posts: 4,583
Threads: 384
Joined: Dec 2004
#16
2014-05-21, 08:09 AM (This post was last modified: 2014-05-21, 08:13 AM by bgowland.)
Just to briefly revisit this (and for future reference).

I changed my requirements for the Now/Next query. The previous query returns two results for each channel (one for Now and the other Next...obviously).

I now need a single result for each channel which combines both. Took some time and gave me a bit of a headache. But I thought I'd share.
Code:
SELECT A.channel_oid AS _id, A.oid AS now_oid, A.title AS now_title, A.start_time AS now_start_time,
       A.end_time AS now_end_time, B.oid AS next_oid, B.title AS next_title, B.start_time AS next_start_time,
       B.end_time AS next_end_time
FROM (
    SELECT channel_oid,
        oid,
        title,
        start_time,
        end_time
    FROM epg_event
    WHERE  start_time <= datetime('now') AND end_time > datetime('now')
    ORDER BY channel_oid) AS A  
JOIN (
    SELECT channel_oid,
        oid,
        title,
        MIN(start_time) as start_time,
        end_time
    FROM epg_event
    WHERE start_time > datetime('now')  
    GROUP BY channel_oid)  AS B
ON A.channel_oid = B.channel_oid
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): « Previous 1 2


Possibly Related Threads…
Thread Author Replies Views Last Post
  Web API only_new Question Gazavant 6 2,652 2021-04-04, 06:54 PM
Last Post: sub
  Another Artwork question scJohn 15 8,125 2019-09-10, 05:33 PM
Last Post: nonob
  WEB API GuidService/Listing question(s) scJohn 6 4,259 2017-08-09, 02:18 PM
Last Post: scJohn
  skin question pBS 2 3,336 2016-06-18, 07:03 PM
Last Post: pBS
  Timing.Info question mvallevand 2 2,064 2013-04-19, 03:54 AM
Last Post: mvallevand
  N-PVR db3 EPG_EVENT time format question bgowland 3 2,077 2011-03-12, 05:26 AM
Last Post: bgowland
  Ping UncleJohnsBand (question about npvr soap) ioan 2 2,036 2011-02-18, 01:12 AM
Last Post: UncleJohnsBand
  Skin question - how to centre a list UiList control on screen? McBainUK 2 1,837 2011-02-17, 08:46 AM
Last Post: McBainUK
  Skin question for "Visible" 7ore 14 5,303 2010-09-22, 09:04 PM
Last Post: sub
  A question about fast incremental updates ACTCMS 12 4,345 2009-12-07, 03:42 AM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode