Click here to Skip to main content
16,005,080 members
Home / Discussions / Database
   

Database

 
GeneralRe: an insert query with return value Pin
reza assar21-May-10 7:32
reza assar21-May-10 7:32 
GeneralRe: an insert query with return value Pin
Luc Pattyn21-May-10 7:41
sitebuilderLuc Pattyn21-May-10 7:41 
GeneralRe: an insert query with return value Pin
J4amieC24-May-10 1:25
J4amieC24-May-10 1:25 
GeneralRe: an insert query with return value Pin
Mycroft Holmes23-May-10 4:26
professionalMycroft Holmes23-May-10 4:26 
GeneralRe: an insert query with return value Pin
Luc Pattyn23-May-10 4:36
sitebuilderLuc Pattyn23-May-10 4:36 
GeneralRe: an insert query with return value Pin
Mycroft Holmes23-May-10 11:07
professionalMycroft Holmes23-May-10 11:07 
GeneralRe: an insert query with return value Pin
Luc Pattyn23-May-10 13:51
sitebuilderLuc Pattyn23-May-10 13:51 
QuestionMultiple columns at GROUP BY clause in CASE clause [modified] Pin
Naunt19-May-10 22:58
Naunt19-May-10 22:58 
Dear CodeProject GURUs,

Please help me, I want to know that can I use multiple columns for GROUP BY clause after using CASE in GROUP BY? Here is my query.
When I execute my query error occour --> Incorrect syntax near ',' <-- at my GROUP BY clause.

declare @num int
set @num= (select ctrqty from ##temp4temp where ctrqty>1)
print @num
SELECT Distinct b.bl_no,b.laden_date , b.container_code , b.shipper_name ,b.consignee_name,sum(b.qty) As FLQty  
FROM docdbdwh.dbo.mastercentral_bl b 
INNER JOIN Credo.dbo.account_code ON b.account_code COLLATE DATABASE_DEFAULT = Credo.dbo.account_code.account_code COLLATE DATABASE_DEFAULT 
inner JOIN ##tmp_ctr2005111852 c ON b.bl_no COLLATE DATABASE_DEFAULT = c.bl_no COLLATE DATABASE_DEFAULT 
	And b.container_code COLLATE DATABASE_DEFAULT = c.container_code COLLATE DATABASE_DEFAULT  
	AND b.vessel_code COLLATE DATABASE_DEFAULT = c.vesselcode COLLATE DATABASE_DEFAULT 
	And b.voyage_no COLLATE DATABASE_DEFAULT = c.voyageno COLLATE DATABASE_DEFAULT 
WHERE ( upper(Credo.dbo.account_code.account_name) like '%FREIGHT%'  and upper(Credo.dbo.account_code.account_name) not like '%FREIGHT REBATE%' ) 
	and b.bl_type <> 'S' and b.bl_no Not In (SELECT bl_no FROM docdbdwh.dbo.MasterCentral_BL WHERE BL_ISSUE = 'IDBDO' AND BL_Type = 'T' )
group by case  @num 
	WHEN  2  THEN 
		(b.bl_no, b.laden_date,b.container_code,b.shipper_name,b.consignee_name,c.status,b.qty) 
	Else 
		(b.bl_no, b.laden_date,b.container_code,b.shipper_name,b.consignee_name)	
	end	


Thanks and Best Regards

modified on Thursday, May 20, 2010 5:24 AM

AnswerRe: Multiple columns at GROUP BY clause in CASE clause Pin
Johan Hakkesteegt19-May-10 23:51
Johan Hakkesteegt19-May-10 23:51 
GeneralRe: Multiple columns at GROUP BY clause in CASE clause Pin
David Skelly20-May-10 0:37
David Skelly20-May-10 0:37 
GeneralRe: Multiple columns at GROUP BY clause in CASE clause Pin
Johan Hakkesteegt20-May-10 0:41
Johan Hakkesteegt20-May-10 0:41 
GeneralRe: Multiple columns at GROUP BY clause in CASE clause Pin
Naunt20-May-10 15:54
Naunt20-May-10 15:54 
QuestionRe: Multiple columns at GROUP BY clause in CASE clause Pin
Chris Meech20-May-10 2:39
Chris Meech20-May-10 2:39 
QuestionRe: Multiple columns at GROUP BY clause in CASE clause Pin
Naunt20-May-10 16:35
Naunt20-May-10 16:35 
AnswerRe: Multiple columns at GROUP BY clause in CASE clause Pin
Johan Hakkesteegt21-May-10 0:47
Johan Hakkesteegt21-May-10 0:47 
AnswerRe: Multiple columns at GROUP BY clause in CASE clause Pin
Chris Meech21-May-10 1:15
Chris Meech21-May-10 1:15 
QuestionSql Server Remote Connection Error Pin
sudheesh kumar s19-May-10 20:30
sudheesh kumar s19-May-10 20:30 
AnswerRe: Sql Server Remote Connection Error Pin
_Damian S_19-May-10 20:36
professional_Damian S_19-May-10 20:36 
GeneralRe: Sql Server Remote Connection Error Pin
sudheesh kumar s19-May-10 21:24
sudheesh kumar s19-May-10 21:24 
QuestionSQL query problem Pin
josephong19-May-10 19:31
josephong19-May-10 19:31 
AnswerRe: SQL query problem Pin
_Damian S_19-May-10 20:19
professional_Damian S_19-May-10 20:19 
GeneralRe: SQL query problem Pin
josephong19-May-10 21:49
josephong19-May-10 21:49 
GeneralRe: SQL query problem Pin
Shameel23-May-10 5:21
professionalShameel23-May-10 5:21 
QuestionCompair Two tables and return result in column Pin
Sachin Pimpale18-May-10 23:41
Sachin Pimpale18-May-10 23:41 
AnswerRe: Compair Two tables and return result in column Pin
Tripathi Swati19-May-10 0:19
Tripathi Swati19-May-10 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.