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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:18:48+00:00 2026-05-31T18:18:48+00:00

I have a table withe different columns as shown below Ref Number Service Numbers

  • 0

I have a table withe different columns as shown below

 Ref Number Service Numbers Service type code   OpenDate    CurrentAppointDt    PreviousAppointDt   Time_Stamp  Lettert_created
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    2/17/12 9:00 AM FALSE
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    3/19/12 9:29 AM FALSE
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    3/19/12 9:30 AM TRUE
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    3/8/12 11:32 AM FALSE
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    3/20/12 9:59 AM FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    2/1/12 9:41 AM  FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    3/21/07 10:00 AM    FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    3/21/07 10:09 AM    FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    3/22/07 11:21 AM    FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    3/27/07 9:01 AM FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    3/27/07 12:19 PM    FALSE
94329   140055  94329   03/21/07    04/20/07    04/02/07    12/2/11 12:55 PM    FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    3/16/12 4:52 PM FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    3/16/12 5:33 PM TRUE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    3/16/12 11:58 AM    FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    3/14/12 2:09 PM FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    2/24/12 2:00 PM FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    2/24/12 12:15 PM    FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    2/24/12 12:15 PM    FALSE

If I take the distinct values for the above Ref Number I get as follows

78892                       
94329                       
107126  

The time_stamp is always between CurrentAppointDT and PreviousAppointDt.
For these RefNumbers I need to see if the ‘Lettercreated’ is False/true.
I need the output as follows:

Ref Number  Service Numbers Service type code   OpenDate    CurrentAppointDt    PreviousAppointDt   Lettert_created
78892   485992  78892TA 02/16/12    04/17/12    03/21/12    TRUE
94329   140055  94329   03/21/07    04/20/07    04/02/07    FALSE
107126  478952  107126TA    02/06/12    03/28/12    02/28/12    TRUE

Please help me if i can get a T-sql script in 1 select statement. It is a great help if any one can give me a solution.
Thank you.

  • 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-05-31T18:18:50+00:00Added an answer on May 31, 2026 at 6:18 pm

    It looks like you’re just looking for the case where the reference number has any record set to “True”, otherwise list it as “False”. If this is the case, try this:

    select Ref_Number, Service_Numbers, Service_type_code, OpenDate, CurrentAppointDt, PreviousAppointDt,
      case max(case when Lettert_created='True' then 1 else 0 end)
        when 1 then 'True'
        else 'False'
      end
    from tbl
    where time_stamp between CurrentAppointDT and PreviousAppointDt
    group by Ref_Number, Service_Numbers, Service_type_code, OpenDate, CurrentAppointDt, PreviousAppointDt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with lots of different columns, like resolution, brightness, type, width,
I have this table: create table demo ( key number(10) not null, type varchar2(3)
I have a table with different values for different countries, for example: id| country
I have table nol_voa with different values and I am importing xml file with
Related to - PostgreSQL DISTINCT ON with different ORDER BY I have table purchases
Is it possible to have same table name on different schema with different data
I have a database table with parent child relationships between different rows. 1 parent
I have two databases at two different places, both databases are same with table
I have a big table with 70 rows and 10 columns. It's a table
I have two columns in my products table, category1, and category2. In my categories

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.