• Skip to main content
  • Skip to primary sidebar

Datannum

Data science for small business applications

  • Home
  • Microsoft Excel (spreadsheet) forum
    • Project: Analyze NYSE Data
  • SQL forum
    • Project: Query a Digital Music Store Database
  • Tableau forum (data visualization)
    • Project: Data Visualization Project using Tableau
  • Linear Algebra forum
    • Curated resource to learn linear algebra
  • Web development
    • WordPress forum
    • Google Support

Naming convention with SELECT of columns: Avoid duplication for display with alias

Data Science for Small Business Applications › Forums › SQL › Naming convention with SELECT of columns: Avoid duplication for display with alias

Tagged: alias names with SELECT

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • July 25, 2022 at 7:41 am #420
    Admin
    Keymaster
      SELECT region.name, sales_reps.name, accounts.name
      FROM region
      JOIN sales_reps
      ON region.id = sales_reps.region_id
      JOIN accounts
      ON accounts.sales_rep_id = sales_reps.id
      ORDER BY accounts.name 
      

      Why am I getting only one column ‘name’ as output while I expected three.


      Reply


      SELECT region.name AS RegionName, sales_reps.name AS salesman, accounts.name AS CompanyName
      FROM region
      JOIN sales_reps
      ON region.id = sales_reps.region_id
      JOIN accounts
      ON accounts.sales_rep_id = sales_reps.id
      ORDER BY accounts.name


      Reference:

      Whether you want to use inner or outer in the final query, using outer now will help you debug https://community.spiceworks.com/topic/2458488-what-is-wrong-with-this-query?page=1#entry-10181316

    • Author
      Posts
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Primary Sidebar

    profile for Techcosec Limited on Stack Exchange, a network of free, community-driven Q&A sites

    RSS CS50’s Introduction to Computer Science by Harvard University on Edx

    • How to print winner January 21, 2023
    • find_min function and infinite loop when a candidate not winner in first instance January 17, 2023
    • Bool variable won and print_winner function January 12, 2023
    • True condition with while loop January 6, 2023
    • How to finally display result in tabular form of choices entered by voters December 12, 2022

    Subscribe via Email

    Enter your email address to subscribe and receive notifications of new posts by email.

    This website hosted on WP Engine

    Initiative by Digital Splendid OPC Pvt. Ltd. & Techcosec Limited