Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:07:26+00:00 2026-06-13T08:07:26+00:00

When I run the following query: SELECT datetime_up, logic_id,eqp_name,ack, created FROM NAS_db.main WHERE TRUNC(datetime_up,’DD’)

  • 0

When I run the following query:

SELECT datetime_up, logic_id,eqp_name,ack, created FROM NAS_db.main
WHERE TRUNC(datetime_up,'DD') >= TO_TIMESTAMP ('04/18/2012', 'MM/DD/YYYY') and
TRUNC(datetime_up,'DD') <= TO_TIMESTAMP ('04/21/2012', 'MM/DD/YYYY') AND eqp_name ='Router-A'
GROUP BY datetime_up,eqp_name, logic_id,ack,created

I get the following output:

datetime_up             logic_id    eqp_name      ack   created
4/19/2012 5:52:04 PM    IP_1.1.1.1_ Router-A       1       0

4/19/2012 5:52:04 PM    IP_1.1.1.1_ Router-A       0       0

Ok, Those are consecutive records, I need to… in the cases like this , that the first record has a 1, to take only that one, instead of 2.

I mean, if I query and I have 1000 records showing a 1 after the RouterA, I will need to take only one, and avoid the other one, if they are only 0s, the same, only take one, so I would like to have my query to show this.

4/19/2012 5:52:04 PM    IP_1.1.1.1_ Router-A       1       0

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:07:27+00:00Added an answer on June 13, 2026 at 8:07 am

    You are grouping by all of the columns, without using any aggregate functions, which is equivalent to select distinct.

    Assuming ack can only be zero or one, you can use max() on that column, and exclude it from the group by:

    SELECT datetime_up, logic_id, eqp_name, max(ack), created
    ...
    GROUP BY datetime_up, eqp_name, logic_id, created
    

    Not sure how created is expected to behave, you might want to do the same to that column too.

    In more complicated situations you could use analytic functions to rank the rows by some criteria and then filter in an outer select, but I think that’s overkill here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run the following query: SELECT COUNT(*) FROM ( SELECT *
If I run the following SQL query SELECT * FROM A LEFT JOIN B
All, If I run a query like the following: $qry = Select wrong_column from
I tried to run the following query: select a,b,min(c) from tablename where e=1 and
I want to run the following query :: SELECT S.* FROM sys.dm_exec_requests S JOIN
I'm using the YQL console to run the following query: select * from xml
I'm trying to run the following query from phpMyAdmin (on a local WAMP server):
I run the following query: SELECT orderdetails.sku, orderdetails.mf_item_number, orderdetails.qty, orderdetails.price, supplier.supplierid, supplier.suppliername, supplier.dropshipfees, cost
I have the following simple MySQL query: SELECT SQL_NO_CACHE mainID FROM tableName WHERE otherID3=19
I am trying to run the following query : SELECT A.STEPNAME, A.BRDATE BRDATE_A, B.BRDATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.