views:

33

answers:

4

Hello All,

Question 1: I am learning SQL Server and Oracle joins (inner joins, outer joins...) and case statements syntax. Though I can google for the info, but would like to ask for some sites, links, and materials that fully explain the joins and case statments. Once again, thanks.

Thanks gentlemen.

Question 2: I am running a simple statment below which gives the output as follow:

select '''' + name + '''' + ',' as Emp_Names from dbo.employee

Emp_Names 'Jason', 'Robert', 'Celia', 'Linda', 'David', 'James', 'Alison', 'Chris', 'Mary',

Is there a way in SQL that can show my desired output as:

Emp_Names 'Jason', 'Robert','Celia','Linda','David','James','Alison','Chris','Mary',

i can press a Delete and End together to get there but only for a handful records but not for a hundred records...

Thanks all!

+2  A: 

You can start here.

Luc M
A: 

Joins are more of general SQL they don't have different commands specific to SQL Server or Oracle. Microsoft has T-SQL and Oracel has PL/SQL. T-SQL - use this link

Praneeth
+1  A: 

SQL Server and Oracle joins (inner joins, outer joins...)

Good link for that.

...case statements syntax.

The CASE expression is ANSI, and supported in Oracle 9i+ and SQL Server 2000+ - it's the same on both. Oracle's PLSQL also has a CASE statement, and the difference between the two is that the PLSQL version ends with END CASE, rather than END.

OMG Ponies
A: 

In SQL Server 2005 or later, you can use the stuff function if you want all the names in one column.

SELECT STUFF(( SELECT DISTINCT TOP 100 PERCENT
                                ',' + Name
                        FROM    employee
                        ORDER BY ',' +Name
                        FOR XML PATH('')
                      ), 1, 1, '') 

or

select STUFF(( SELECT DISTINCT TOP 100 PERCENT
                                ''',''' + Name
                        FROM    employee 
                        ORDER BY ''',''' + Name
                        FOR XML PATH('')
                      ), 1, 2, '') + ''''      

Otherwise you could use the pivot command to have each name as its own column. The only thing with using the pivot command is that you need to know the names before hand or else you would use it in conjunction with the stuff function.

clyc