Viewing 14 posts - 16 through 29 (of 29 total)
As you haven't posted the complete list of tables you have to work with and the full view of results you want to get (you've posted a simplified version), I've...
June 12, 2012 at 9:10 pm
ChrisM@Work (6/12/2012)
Good grief, this thread reads like a traincrash.
Maybe it does, but if you take a look at my join-based solution (which I've offered above), you'll see that it doesn't...
June 12, 2012 at 2:35 am
And here's my version with use of pivot:
select style,lbl,div
from (
select
a.style,
c.type_name,
b.group_name
from
zzxstylr as a
join zzxpgtyr as c
on c.type_name='LBL'
or c.type_name='DIV'
/*or (on c.pkey=1 or c.pkey=8) if you like*/
/*determine the group_type corresponding to the group_col1...
June 12, 2012 at 1:16 am
vinu512 (6/11/2012)
Any Logic could be applied to get an expected Result Set.
By the way, if any logic could be applied, why wouldn't you suggest the simplest solution:select * from (values...
June 12, 2012 at 12:26 am
vinu512 (6/11/2012)
But in your case there doesn't seem to be a fixed universal Logic.
Without a clear logic there could be...
June 11, 2012 at 11:56 pm
Here's my old version that now has been renewed and that now uses aliases.
By the way, pay attention to the comment where I suggest to compare not only group_type and...
June 11, 2012 at 11:27 pm
I'm not a pro in this area, but as I understand, «Min(Group_Name)» — isn't a the right rule that correctly determines which group corresponds to the style. As I understood, the...
June 11, 2012 at 11:11 pm
Check out my previous post, 'cause it seems that I've found a solution to your problem while you were correcting the mistypes 🙂
UPD! 'Check out my previous post'S! My solution...
June 11, 2012 at 3:46 pm
This is the solution of your problem:
Oops… 🙁 While editing this post I accidentally deleted all the text except sql-code. Though, it steel works.
select
zzxstylr.style,
lbl_zzxpgrpr.group_name as lbl,
div_zzxpgrpr.group_name as div
from
zzxstylr...
June 11, 2012 at 3:10 pm
And these are results i have when executing your query:
It's only 3 lines here, not 8 like you wrote… Do I do something wrong?
June 11, 2012 at 2:23 pm
CREATE TABLE zzxstylr
(division FK varchar(3),style varchar(12),group_code1 varchar(9),group_code2 varchar(9),group_code3 varchar(9),
group_code4 varchar(9),group_code5 varchar(9),group_code6 varchar(9),group_code7 varchar(9),group_code8 varchar(9))
INSERT INTO zzxstylr
VALUES ('MDG','2204852','02', '', '', '', '', '', '', '01')
CREATE TABLE zzxpgrpr
(division varchar(3), group_type varchar(1),group_code varchar(9),group_name...
June 11, 2012 at 2:16 pm
The code you've posted contains mistypes (it doesn't work in ssms). It means you didn't tested your code yourself. Would you like us to post unworking code too? 🙂
June 11, 2012 at 2:09 pm
I completely agree with Sean and Lynn: post, please, DDL-code (the definitions of your tables (including foreign key constraints)) and DML-code (sample data) and the results you want to have.
Moreover,...
June 11, 2012 at 1:02 pm
I'm not a professional in SQL, I'm a newbie.
But I think I could help… As I understand, you have this:
style_table:
style | group_code1 | … | group_code8
--------+-------------+---+-------------
style1 |...
June 11, 2012 at 4:12 am
Viewing 14 posts - 16 through 29 (of 29 total)