Home > database >  How to get the same number of quantity together
How to get the same number of quantity together

Time:10-29

Data syntax is as follows, could you tell me how can the same number and line number together for a total number of

The SELECT OR19001 AS [orders], SL01002 AS [customer], OR19002 + '-' + OR19003 AS [line number], OR03005 AS [code] products, OR03006 + '-' + OR03007 AS [specification], OR19007 AS number] [delivery, OR19011 AS/delivery date FROM OR03DP00
The JOIN SL01DP00 ON OR03119=SL01001
The JOIN OR19DP00 ON OR19001=OR03001 AND OR19002=OR03002
WHERE OR03119='S104268 AND OR03012 & lt;> 0 AND OR19011=the convert (varchar (10), getdate (), 120)

Like there are also many single number and line number is the same


The effect of the last I want to do

CodePudding user response:

Try the aggregation function + group by single number, line number

CodePudding user response:

No wrong
Message 156, level 15, state 1, line 2
Incorrect syntax near the keyword 'JOIN'.

CodePudding user response:

The join is associated query, aggregation function is similar to the sum, count, Max

CodePudding user response:

You feel it is more after the JOIN line line, determine the amount to add up to?
If it is the reference:
 
The SELECT OR19001 AS [orders], SL01002 AS [customer], OR19002 + '-' + OR19003 AS [line number], OR03005 AS [code] products, OR03006 + '-' + OR03007 AS [specification], the SUM (OR19007) AS number] [delivery, OR19011 AS/delivery date FROM OR03DP00
The JOIN SL01DP00 ON OR03119=SL01001
The JOIN OR19DP00 ON OR19001=OR03001 AND OR19002=OR03002
WHERE OR03119='S104268 AND OR03012 & lt;> 0 AND OR19011=the convert (varchar (10), getdate (), 120)
Group by OR19001, OR19002 + '-' + OR19003, OR03005, OR03006 + '-' + OR03007, OR19011

CodePudding user response:

And the wrong, according to your guide test

The SELECT OR19001 AS [orders], SL01002 AS [customer], OR19002 + '-' + OR19003 AS [line number], OR03005 AS [code] products, OR03006 + '-' + OR03007 AS [specification], OR19007 AS number] [delivery, OR19011 AS/delivery date FROM OR03DP00
The JOIN SL01DP00 ON OR03119=SL01001
The JOIN OR19DP00 ON OR19001=OR03001 AND OR19002=OR03002
WHERE OR03119='S104268 AND OR03012 & lt;> 0 AND OR19011=the convert (varchar (10), getdate (), 120)
Group by OR19001, OR19002 + '-' + OR19003, OR03005, OR03006 + '-' + OR03007, OR19011

CodePudding user response:

Error below

Message 8120, level 16, state 1, line 1
The Column 'SL01DP00. SL01002' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

CodePudding user response:

 SELECT OR19001 AS [orders] 
, OR19002 + '-' + OR19003 AS [line number]
, OR03005 AS [product code]
, OR03006 + '-' + OR03007 AS [specification]
, the sum (OR19007) AS [delivery number]
, OR19011 AS [delivery date]
The FROM OR03DP00
The JOIN SL01DP00 ON OR03119=SL01001
The JOIN OR19DP00 ON OR19001=OR03001 AND OR19002=OR03002
WHERE OR03119='S104268 AND OR03012 & lt;> 0 AND OR19011=the convert (varchar (10), getdate (), 120)
Group by OR19001 OR19002, OR19003 OR03005, OR03006, OR03007, OR19011


No fields to group by group, is listed by aggregation function calculation

CodePudding user response:

Right now, thank you (illiterate old gu)

  • Related