473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to select the duplicate value if both are in the same interval

Hi,

can anyone help me to figure this out.
Currently, i have this code:
Expand|Select|Wrap|Line Numbers
  1. select 
  2.   t_stamp, 
  3.   num 
  4. from table
  5. where num in 
  6.    (select num from click_log 
  7.     where t_stamp between '2010-07-21 12:00:00' 
  8.     and '2010-07-21 13:00:00'
  9.     group by num 
  10.     having count(*) > 1)
  11. order by num;
  12.  
this code will get the duplicate values within interval of 1 hour. This is not the problem. the problem is how to get duplicate values for every 15 mins of time range (0-15,15-30,30-45,45-60) within interval of 1 hour.

lets say if my records look like this:
Expand|Select|Wrap|Line Numbers
  1. tstamp              | num
  2. --------------------+-----
  3. 2010-07-21 11:59:05 |  a
  4. 2010-07-21 12:05:23 |  a
  5. 2010-07-21 12:08:47 |  c
  6. 2010-07-21 12:11:30 |  a
  7. 2010-07-21 12:18:11 |  a
  8. 2010-07-21 12:24:09 |  b
  9. 2010-07-21 12:33:41 |  a
  10. 2010-07-21 12:35:29 |  b
  11. 2010-07-21 12:39:09 |  b
  12. 2010-07-21 12:43:51 |  a
  13. 2010-07-21 12:45:17 |  a
  14. 2010-07-21 12:49:05 |  c
  15. 2010-07-21 12:56:00 |  c
  16. 2010-07-21 13:10:32 |  a
  17.  
  18. the output should be look like this:
  19.  
  20. tstamp              | num
  21. --------------------+-----
  22. 2010-07-21 12:05:23 |  a    } in 0-15mins
  23. 2010-07-21 12:11:30 |  a    }
  24. _________________________
  25. 2010-07-21 12:33:41 |  a    } in 30-45mins
  26. 2010-07-21 12:35:29 |  b    }
  27. 2010-07-21 12:39:09 |  b    }
  28. 2010-07-21 12:43:51 |  a    }
  29. _________________________
  30. 2010-07-21 12:49:05 |  c    } in 45-60mins
  31. 2010-07-21 12:56:00 |  c    }
  32.  
I appreciate any help.

thanks :)
Jul 30 '10 #1
2 2410
fyi, i'm using postgres 8.2 :)
Jul 30 '10 #2
rski
700 Expert 512MB
All ranges in one query? Can you use UNION clauses?
Aug 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
4
by: markus.rietzler | last post by:
onChange() is working very well, when an option is choosen the first time. how can i detect when the user clicks and choose the same option again? this code works with IE 6.x. you can click the...
4
by: Matt Kruse | last post by:
According to standards, if an option is selected and it has no VALUE attribute, the contents of the option tag is to be submitted. So: <select name="sel"> <option selected>Value</option>...
2
by: Gary Dale | last post by:
I have a form with a pull-down list with six options, each of which has a value set. The value is the e-mail account name (without the domain) of a group while the displayed value is the full name...
3
by: jerrys57 | last post by:
Hi All, Need some help with a listbox display to textbox...After loading my listbox from the database, I need to be able to select duplicate names and display them in a textbox....it works fine on...
5
by: lyne_asp | last post by:
Hello everbody, Please help me to remove the duplicate value. I have this code Do until objRSEmail.eof tgroup = objRSEmail("tEmailName")&"@city.com;"&tgroup ...
4
by: lucky13 | last post by:
Dear All, can u help in how to check the duplicate value in the listview control before adding new in the list. Regards Lucky13
1
by: vishwa Ram | last post by:
Hi ScriptFamily, I need to remove a duplicate value in array. Any specific method available in perl. pls suggest Regards Raam
3
by: ashishc | last post by:
Hi All, I have written a AutoSuggest in jsp and am using javascript to call the strut page which calls the database and returns me the xml back. On the html page i have a text box where i enter...
3
by: spl | last post by:
What is the fastest way to find a duplicate value in an array of 10 elements. I have to find just any one first occurrence of the duplication. Lets say I have ary={10, 20, 40, 90, 30, 60, 35, 40,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.