sql server - SQL Stored Procedures : Count, Join and group by but it is shown 'NULL' -


i got stuck stored procedures write stored need shot 3 columns of products count this

select      count([tpdtn].[productname]) 'product count',     [tpdtn].[categoryid]      [tpdtn] left join      [tpdcn] on [tpdtn].[categoryid] = [tpdcn].[libdocumentid] group      [tpdtn].[categoryid], [tpdcn].[libdocumentid] 

it shows results this:

   product count    categoryid    ---------------------------         2               1         9               2         2               3         2               4         1               5 

but don't know how make show

   product count    categoryid       libdocumentid    -----------------------------------------------         2               1               123456789         9               2               123456789         2               3               123456789         2               4               123456789         1               5               123456789 

producer id (libdocumentid) other table when select [tpdcn].[libdocumentid] value null

product count    categoryid       libdocumentid ------------------------------------------------     2               1               null     9               2               null     2               3               null     2               4               null     1               5               null 

how can solve it? thank you

just add select, , if don't need null need inner join:

select count([tpdtn].[productname]) 'product count',[tpdtn].[categoryid], [tpdcn].[libdocumentid] [tpdtn] inner join [tpdcn] on [tpdtn].[categoryid] = [tpdcn].[libdocumentid] group [tpdtn].[categoryid],[tpdcn].[libdocumentid] 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -