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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:54:51+00:00 2026-05-17T00:54:51+00:00

I am trying to pull some data out of our testing database with an

  • 0

I am trying to pull some data out of our testing database with an sql query and i am stuck. Below is a representation of how the data looks when I run it and how it should look once it is run.

What I get

Sample_Number  Centre_Code  DateEntered  AssayName
---------------------------------------------------
1              234          9/16/2010    TEST 1
1              234          9/16/2010    TEST 2
1              234          9/16/2010    TEST 3
1              234          9/16/2010    TEST 4
1              234          9/16/2010    TEST 5         
2              345          9/17/2010    TEST 1
2              345          9/17/2010    TEST 2
2              345          9/17/2010    TEST 3         
3              456          9/16/2010    TEST 1
3              456          9/16/2010    TEST 2
3              456          9/16/2010    TEST 3
3              456          9/16/2010    TEST 4
3              456          9/16/2010    TEST 5
3              456          9/16/2010    TEST 6
3              456          9/16/2010    TEST 7

What I am trying to get

Sample_Number  Centre_Code  DateEntered  ProfileName
-----------------------------------------------------                       
1              234          9/16/2010    PROFILE 1          
2              345          9/17/2010    PROFILE 2          
3              456          9/16/2010    PROFILE 3

The problem I am having is I have these testing profiles where a specific set of tests make up a profile for each sample and I cannot get them to group into profiles, I can only get the individual tests. I was thinking of using CASE in the query and specifying what each profiles tests are, but that doesn’t seem efficient and it is also beyond the limit of my sql knowledge. Here is the query I have so far.

SELECT     User.Sample.Sample_Number,User.Centre.Centre_Code, User.Sample.DateEntered, User.Assay.AssayName
FROM         User.Sample INNER JOIN
                      User.Centre ON User.Sample.Centre_ID = User.Centre.Centre_Id INNER JOIN
                      User.Profile ON User.Sample.Profile_ID = User.Profile.Profile_ID INNER JOIN
                      User.Batch ON User.Sample.Batch_ID = User.Batch.Batch_ID INNER JOIN
                      User.SampleResult ON User.Sample.Sample_ID = User.SampleResult.Sample_ID INNER JOIN
                      User.Assay INNER JOIN
                      User.Result ON User.Assay.Assay_ID = User.Result.Assay_ID ON 
                      User.SampleResult.Assay_ID = User.Assay.Assay_ID AND User.SampleResult.Result_ID = User.Result.Result_ID INNER JOIN
                      User.Test ON User.Profile.Profile_ID = User.Test.Profile_ID AND User.Assay.Assay_ID = User.Test.Assay_ID
WHERE     (User.Sample.DateEntered > CONVERT(DATETIME, '2010-09-01 23:59:59', 102)) AND (User.Sample.DateEntered < CONVERT(DATETIME, 
                      '2010-09-20 00:00:00', 102))
GROUP BY User.Sample.DateEntered, User.SampleResult.Sample_ID, User.Assay.AssayName, User.Centre.Centre_Code, 
                      User.Sample.Sample_ID, User.Sample.Sample_Number

For reference

Profile 1 = Test 1, Test 2, Test 3, Test 4, Test 5

Profile 2 = Test 1, Test 2, Test 3

Profile 3 = Test 1, Test 2, Test 3, Test 4, Test 5, Test 6, Test 7

Each test in a profile will have the same sample number, centre code, and date entered.

Is there anything I can do to the sql query or even in excel to manipulate it once I have run the query?

  • 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-17T00:54:52+00:00Added an answer on May 17, 2026 at 12:54 am

    How about setting up the relationship between profiles and tests in another DB table and joining on that table? That way you could select/group on the profile name which is what you want, not the test name

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

Sidebar

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.