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

  • SEARCH
  • Home
  • 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 8901819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:27:21+00:00 2026-06-15T01:27:21+00:00

Hey i have a query ordered by date, and i want in case the

  • 0

Hey i have a query ordered by date, and i want in case the date is identical to order by time added to maintain stable results.

I have the following query :

    (
SELECT  'album' AS RowType, id, DATE, title, time_added
FROM albums
WHERE is_temp =0
AND subject_id =  '3'
)
UNION ALL (

SELECT  'video' AS RowType, id, DATE, title, time_added
FROM videos
WHERE is_temp =0
AND subject_id =  '3'
)
UNION ALL (

SELECT  'story' AS RowType, id, DATE, title, time_added
FROM stories
WHERE is_temp =0
AND subject_id =  '3'
)
ORDER BY DATE, time_added

Which works perfectly but i don’t want to select the time_added column as i don’t need it in my result set.

Can i somehow achive this? if i remove the time_added the query won’t run.

I have found the following :

The ORDER BY clause causes the output rows to be sorted.
The argument to ORDER BY is a list of expressions that are used as the
key for the sort. The expressions do not have to be part of the result
for a simple SELECT, but in a compound SELECT each sort expression
must exactly match one of the result columns. Each sort expression may
be optionally followed by a COLLATE keyword and the name of a
collating function used for ordering text and/or keywords ASC or DESC
to specify the sort order.

Which i can’t decide if means it’s impossible or i should try harder.

  • 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-15T01:27:22+00:00Added an answer on June 15, 2026 at 1:27 am

    try this

    SELECT RowType
        , id
        , DATE
        , title
    FROM 
    (
        SELECT 'album' AS RowType , id , DATE , title , time_added
        FROM albums
        WHERE is_temp = 0 AND subject_id = '3'
    
        UNION ALL
    
        SELECT 'video' AS RowType , id , DATE , title , time_added
        FROM videos
        WHERE is_temp = 0 AND subject_id = '3'
    
        UNION ALL
    
        SELECT 'story' AS RowType , id , DATE , title , time_added
        FROM stories
        WHERE is_temp = 0 AND subject_id = '3'
    
    ) s
    ORDER BY DATE , time_added
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all i have the following query: SELECT REPLACE(REPLACE(REPLACE(REPLACE(tmpTable.Caller_Number,'-',''),'(',''),')',''),' ','') FROM tmpTable WHERE EXISTS
Hey guys, i have the following problem: 1 process executes a very large query
Hey guys, I have the following query and for the life of me I
Hey guys I have a query that currently finds the latest comment for each
Hey - I have the following method on my UITableView controller public void RemoveEventFromList(Event
Hey guys I have a query that selects data and organizes but not in
Hey I have some problems creating my query into doctrine: My sql query looks
Hey, I have a hyperlink column. I need to add just one query string
Hey, I'm trying to query the words which have the maximul values in the
Hey guys, I have a problem with the following table: CREATE TABLE [dbo].[CA]( [Id]

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.