Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Antonio
Posting Yak Master
168 Posts |
Posted - 2007-02-02 : 12:08:36
|
Hi there,Why doesn't the following work?! What am I missing here?select btg_opty_id, result_type_number, 'c' as afrom RESULT_FACT_ETL_OUTPUTgroup by btg_opty_id, result_type_number, 'c' _________________________________________________________________________________________________________________________Inability is a disaster; patience is bravery; abstinence is a treasure, self-restraint is a shield; and the best companion is submission to Divine Will. |
|
PurpleSun
Yak Posting Veteran
50 Posts |
Posted - 2007-02-02 : 12:13:50
|
Why do you need group by? Use order by instead.quote: Originally posted by Antonio Hi there,Why doesn't the following work?! What am I missing here?select btg_opty_id, result_type_number, 'c' as afrom RESULT_FACT_ETL_OUTPUTgroup by btg_opty_id, result_type_number, 'c' _________________________________________________________________________________________________________________________Inability is a disaster; patience is bravery; abstinence is a treasure, self-restraint is a shield; and the best companion is submission to Divine Will.
|
 |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-02-02 : 12:23:50
|
Remove the 'c' in the GROUP BY because this is just a literal and you don't need it there:select btg_opty_id, result_type_number, 'c' as afrom RESULT_FACT_ETL_OUTPUTgroup by btg_opty_id, result_type_numberSQL Server Helperhttp://www.sql-server-helper.com |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-02 : 14:27:08
|
select distinct btg_opty_id,result_type_number,'c' as afromRESULT_FACT_ETL_OUTPUTPeter LarssonHelsingborg, Sweden |
 |
|
Antonio
Posting Yak Master
168 Posts |
Posted - 2007-02-06 : 04:10:07
|
quote: Originally posted by sshelper Remove the 'c' in the GROUP BY because this is just a literal and you don't need it there:select btg_opty_id, result_type_number, 'c' as afrom RESULT_FACT_ETL_OUTPUTgroup by btg_opty_id, result_type_numberSQL Server Helperhttp://www.sql-server-helper.com
Thanks for your help. That worked. _________________________________________________________________________________________________________________________Inability is a disaster; patience is bravery; abstinence is a treasure, self-restraint is a shield; and the best companion is submission to Divine Will. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-06 : 04:32:21
|
Speed wise, how does that approach (group by) compare with DISTINCT?Peter LarssonHelsingborg, Sweden |
 |
|
Antonio
Posting Yak Master
168 Posts |
Posted - 2007-02-07 : 12:22:53
|
quote: Originally posted by Peso Speed wise, how does that approach (group by) compare with DISTINCT?Peter LarssonHelsingborg, Sweden
I've not really tested the speed of the different approaches but there was a time when using DISTINSCT was considered slower that using a GROUP BY clause._________________________________________________________________________________________________________________________Inability is a disaster; patience is bravery; abstinence is a treasure, self-restraint is a shield; and the best companion is submission to Divine Will. |
 |
|
|
|
|
|
|