Jump to content

Recommended Posts

Hello All -

I am new to SQL joins and I am having a difficulty grabbing data from another table.

The table I am primarily running select statements on to output the information I need is HRO. I am wanting to grab some data from the StoreInfo table, but, I cannot seem to get the INNER JOIN function to work. I get this "the multiplier identifier could not be bound."

What am I doing wrong? Please see the code below.

use ROWDW;

select 

store_UIN.HRO, store_UIN.StoreInfo
FORMAT(SUM(total-tax), 'C', 'en-us') AS 'Sales ending 02/06/2016',
COUNT(RO_NO) as 'Car Count',
FORMAT(((SUM((total-tax-t_cost)-(p_cost-supplies))/SUM(total-tax-supplies))), 'P', 'en-us' ) as GPM


from HRO 
inner join StoreInfo 
on store_UIN.HRO = store_UIN.StoreInfo



where
( PAY_DATE >= '01/31/2016') And (PAY_DATE <= '02/06/2016') and [Status] = 'C'  

group by store_UIN

Thanks in advance for your help.

Link to post
Share on other sites

When you join two tables, the ON clause must associate a field of one table to a field of the other table. Currently you're associating two fields from the same table. You also are only selecting fields from one of the tables and not the other.

 

Here's an example of how to properly do a join

SELECT
  table1.field,
  table2.otherfield
FROM table1
INNER JOIN table2
  ON table1.id = table2.id
WHERE table1.field < 10
  • Like 1
Link to post
Share on other sites
  • 3 years later...

You have a select only one table from fetch data in your query. Join the two table using sql query you need to on clause after matching id from both table

select table1.column1, table1.column2, table2.column1....

from table 1

Inner join table 2

On table 1.matching_column = table 2.matching_column

where table1.column2 < 10

 

Edited by Sherin
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...