Select count (a.n ame_id) from (select name_id, sex_id from profile where sex_id='M') a;
, under the hints I message
Incorrect syntax near the keyword "select". Countinue?
I am using 10 version of the original concept
CodePudding user response:
Trial on PB 9, there is no problem.CodePudding user response:
What database?CodePudding user response:
Like this?Select count (name_id) from (select name_id, sex_id from profile where sex_id='M') a;
Your statement can like directly is then.
Select count (name_id) from profile where sex_id='M'.
Select count (1) from the profile where sex_id='M'.
Select count (*) from the profile where sex_id='M'.
CodePudding user response:
My is the sybase databaseWell, for example
The Table A
Pur_nbr item order_nbr
A01 A ORD001
A01 ORD001 B
A01 ORD002 C
How A02 A ORD003
How A02 A ORD003
How A02 A ORD004
Table B
Order_nbr order_qty
ORD001 100
ORD002 200
ORD003 300
ORD004 400
All I want is the result of each pur_nbr statistics used order_nbr order_qty, A01 have two order_nbr (ORD001 ~ 002), the total order_qty=300 how A02 is two (ORD003 ~ 004), a total of 700
Pur_nbr order_qty
A01 300
How A02 700
I was writing is
The select Amy polumbo ur_nbr, b.s um (order_qty)
The from TableA a, TableB b
Where a.o rder_nbr=b.o rder_nbr group by Amy polumbo ur_nbr;
But it is the result of the
Pur_nbr order_qty
A01 400 & gt;>> 100 + 100 + 200
1000 how A02 & gt;> 300 + 300 + 400
CodePudding user response:
Select count (a.n ame_id) into: XXX from...CodePudding user response:
Then I just speak by the way, with money toThe select Amy polumbo ur_nbr, sum (b.o rder_qty) from (select distinct pur_nbr, order_nbr from TableA) as a
Inner join TableB b on a.o rd_nbr=b.o rd_nbr
Group by Amy polumbo ur_nbr
;
Run ~ appear the message
Incorrect syntax near the keyword "select". Countinue?
Please supervise your predecessors taught... I'm dizzy...
CodePudding user response:
I tried, no problem in the SQL Server 2000.It won't be sybase does not support this nested?
CodePudding user response:
Here is the original concept discussion, isn't it... .==CodePudding user response:
I found that... Do the subquery sybase does not support in the from...Predecessors have what grammar can do, please? A temporary table?
CodePudding user response:
The select Amy polumbo ur_nbr, sum (distinct b.o rder_qty) from table_a a, table_b bWhere a.o rder_nbr=b.o rder_nbr
Group by Amy polumbo ur_nbr
;
CodePudding user response:
Sybase database is usedCodePudding user response:
The