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 7850113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:44:57+00:00 2026-06-02T18:44:57+00:00

I have this query which pulls the data correctly but I’d like the timestamp

  • 0

I have this query which pulls the data correctly but I’d like the timestamp field (TIM) to be in another format than Day(TIM). But I get errors because the query is aggregating that way.

SELECT
DAY(TIM) As 'Day',
[G.TRU] = SUM(case when SEC = 'TRU' and TYP = 'GEO' then 1 else 0 end),
[G.LOA] = SUM(case when SEC = 'LOA' and TYP = 'GEO' then 1 else 0 end),
[G.SEA] = SUM(case when SEC = 'SEA' and TYP = 'GEO' then 1 else 0 end),
[R.SEA] = SUM(case when SEC = 'SEA' and TYP = 'RTE' then 1 else 0 end),
TOTAL  = COUNT(TIM)
FROM AGEO
WHERE SRC = 'EW'
GROUP BY DAY(TIM)

Result:

 Day   G.TRU    G.LOA   G.SEA   R.SEA   TOTAL
-----------------------------------------------
 25      2        4       14      1      21
 26      3        0        2      9      14
----------------------------------------------- 

I’d prefer the 25 and 26 to be in a YYYY-MM-DD format. Is there a way?

  • 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-02T18:45:00+00:00Added an answer on June 2, 2026 at 6:45 pm

    No – you’re grouping by DAY(TIM) so there could be various different months and years giving the same day. For example, suppose you had two rows, one on the first of January and one on the first of February – they will be aggregated together, so which one would you expect to retrieve for that result row?

    EDIT: Okay, I’m not a SQL guy, but I think you want something like:

    SELECT
        CONVERT(Date, TIM) As TIMDATE,
        [G.TRU] = SUM(case when SEC = 'TRU' and TYP = 'GEO' then 1 else 0 end),
        [G.LOA] = SUM(case when SEC = 'LOA' and TYP = 'GEO' then 1 else 0 end),
        [G.SEA] = SUM(case when SEC = 'SEA' and TYP = 'GEO' then 1 else 0 end),
        [R.SEA] = SUM(case when SEC = 'SEA' and TYP = 'RTE' then 1 else 0 end),
        TOTAL  = COUNT(TIM)
    FROM AGEO
    WHERE SRC = 'EW'
    GROUP BY TIMDATE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query which works correctly in MySQL. More background on it here
Right now I have this SQL query which is valid but always times out:
I have this query. It matches anything which has South in its name. But
I have a query which produces a list of orders like this: Invoice Description
I have this file 'gardens.php' , which pulls data from a table called 'generalinfo'
I have this query which returns a result set with Date(column) as nvarchar datatype.
So I have this app which needs to query entities from the Azure Tables
I have this query working but it is not returning back exactly what I
I have a field in my table which contains categories data eg Computer >
I have a View that is pretty complex. The query pulls data from about

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.