MichaelRSnow
Active Member
- Joined
- Aug 3, 2010
- Messages
- 409
Does anyone know much about writing SQL queries, I have a basic knowledge and trying unsuccessfully to do something
I have created a JOIN to a table of data but i have duplicate ID's with different corresponding values in another column
[TABLE="class: grid, width: 500, align: center"]
[TR]
[TD]ID[/TD]
[TD]System[/TD]
[TD]Channel[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]11111[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]22222[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[/TABLE]
I want to write a query that searches the ID and returns the channel as a Y or N
But I'm finding that this not returning any requests on 12345 when on multiple rows applied to multiple channels?
Any ideas would be helpful, can't find anything on Google?
I have created a JOIN to a table of data but i have duplicate ID's with different corresponding values in another column
[TABLE="class: grid, width: 500, align: center"]
[TR]
[TD]ID[/TD]
[TD]System[/TD]
[TD]Channel[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]12345[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]11111[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]22222[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[/TABLE]
I want to write a query that searches the ID and returns the channel as a Y or N
Code:
, CASE WHEN Channel = 1 Then 'Y'
ELSE 'N'
END As 'Online'
, CASE
WHEN Channel = 2 Then 'Y'
ELSE 'N'
END As 'Direct'
But I'm finding that this not returning any requests on 12345 when on multiple rows applied to multiple channels?
Any ideas would be helpful, can't find anything on Google?