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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:17:55+00:00 2026-06-01T23:17:55+00:00

I was told to rewrite thie following query with a nested query without joins

  • 0

I was told to rewrite thie following query with a nested query without joins for better performance. Is it true? If so, how to rewrite it?

SELECT distinct A.Company_Name,C.Outlet_Name,
       C.Outlet_FCE_ID,D.Usergroup_Name
FROM   company A, PURCHASE_INVOICE B, 
       Outlet C, User_Group D,CT_USER E
WHERE A.Company_ID = B.Company_ID AND B.Outlet_ID  = C.Outlet_ID 
  AND B.Company_ID = C.Company_ID AND B.Username   = E.Username 
  AND E.Usergroup_ID=D.Usergroup_ID

Here is the table structure.

enter image description here

  • 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-01T23:17:57+00:00Added an answer on June 1, 2026 at 11:17 pm

    Let me answer my own question. I don’t like it this way, but here we go….

        SELECT  distinct
            ( SELECT    Company_Name
              FROM      dbo.COMPANY
              WHERE     Company_ID = p.Company_ID
            ) AS 'CompanyName' ,
            ( SELECT    Outlet_Name
              FROM      dbo.OUTLET
              WHERE     Company_ID = p.Company_ID
                        AND Outlet_ID = p.Outlet_ID
            ) AS 'OutletName' ,
            ( SELECT    Outlet_FCE_ID
              FROM      dbo.OUTLET
              WHERE     Company_ID = p.Company_ID
                        AND Outlet_ID = p.Outlet_ID
            ) 'OutletFCEID' ,
            ( SELECT    Usergroup_Name
              FROM      dbo.USER_GROUP
              WHERE     Usergroup_ID IN ( SELECT    Usergroup_ID
                                          FROM      CT_USER
                                          WHERE     Username = p.UserName )
            ) 'UsergroupName'
    FROM    dbo.PURCHASE_INVOICE p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a previous question I was told how to rewrite my computation expressions so
I've been told by people that Microsoft's IIS Rewrite 2.0 for use on my
Someone told me if I set the ValidateConnection property in Oracle to TRUE, the
someone told me the following table isn't fit for the second database normalization. but
I am trying to rewrite a javascript function since I was told this function
I was told the following was possible due to changes in C++11: class SomeType
Someone told me that openGL is for graphic only, and that it's very bad
Someone told me to do this in order to keep track of latest people
Someone told me once there was a good novel around the story of the
I was told that the optimal way to program in C++ is to use

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.