Click here to Skip to main content
16,010,473 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Procedures help plz... Pin
Eric Dahlvang21-Sep-06 8:16
Eric Dahlvang21-Sep-06 8:16 
QuestionSaving hashtable to sqlexpress database...Is is possible Pin
haomeister20-Sep-06 18:08
haomeister20-Sep-06 18:08 
AnswerRe: Saving hashtable to sqlexpress database...Is is possible Pin
jigneshelegant120-Sep-06 20:20
jigneshelegant120-Sep-06 20:20 
AnswerRe: Saving hashtable to sqlexpress database...Is is possible Pin
Scott Serl21-Sep-06 7:56
Scott Serl21-Sep-06 7:56 
QuestionSQL Query help Pin
picazo20-Sep-06 12:20
picazo20-Sep-06 12:20 
AnswerRe: SQL Query help Pin
albCode20-Sep-06 20:48
albCode20-Sep-06 20:48 
AnswerRe: SQL Query help Pin
Khawar Abbas120-Sep-06 23:49
Khawar Abbas120-Sep-06 23:49 
AnswerRe: SQL Query help Pin
i.j.russell21-Sep-06 2:22
i.j.russell21-Sep-06 2:22 
This is the standard way of doing a Crosstab/PIVOT in SQL.

SELECT Basket,
SUM(CASE FruitID WHEN 1 THEN Amount ELSE 0 END) AS Apple,
SUM(CASE FruitID WHEN 2 THEN Amount ELSE 0 END) AS Orange,
SUM(CASE FruitID WHEN 3 THEN Amount ELSE 0 END) AS Pear
FROM Baskets
GROUP BY Basket

However, as you can see, you need to know in advance what the columns are. There is a new PIVOT command in SQL Server 2005 that may extend this functionality.

The other way is to de-normalise the data using

SELECT b.basket, f.FruitName, b.Amount
FROM Baskets b INNER JOIN Fruit f on b.FruitID = f.FruitID

and import it into Excel where you can use the Pivot tool to do the crosstabbing for you.

Ian
AnswerRe: SQL Query help Pin
Eric Dahlvang21-Sep-06 4:03
Eric Dahlvang21-Sep-06 4:03 
QuestionOracle Question Pin
Ennis Ray Lynch, Jr.20-Sep-06 8:14
Ennis Ray Lynch, Jr.20-Sep-06 8:14 
AnswerRe: Oracle Question Pin
Farhan Noor Qureshi20-Sep-06 11:03
Farhan Noor Qureshi20-Sep-06 11:03 
GeneralNot really Pin
Ennis Ray Lynch, Jr.20-Sep-06 11:24
Ennis Ray Lynch, Jr.20-Sep-06 11:24 
AnswerRe: Oracle Question Pin
Eric Dahlvang20-Sep-06 12:09
Eric Dahlvang20-Sep-06 12:09 
GeneralRe: Oracle Question Pin
Ennis Ray Lynch, Jr.20-Sep-06 14:57
Ennis Ray Lynch, Jr.20-Sep-06 14:57 
QuestionDatatables, rows and columns Pin
TheJudeDude20-Sep-06 8:11
TheJudeDude20-Sep-06 8:11 
AnswerRe: Datatables, rows and columns Pin
albCode20-Sep-06 20:56
albCode20-Sep-06 20:56 
GeneralRe: Datatables, rows and columns Pin
TheJudeDude21-Sep-06 2:26
TheJudeDude21-Sep-06 2:26 
QuestionSqlException - 'Login failed for user (user)' Pin
nlindley720-Sep-06 6:55
nlindley720-Sep-06 6:55 
AnswerRe: SqlException - 'Login failed for user (user)' Pin
Colin Angus Mackay20-Sep-06 22:31
Colin Angus Mackay20-Sep-06 22:31 
GeneralRe: SqlException - 'Login failed for user (user)' Pin
nlindley721-Sep-06 7:07
nlindley721-Sep-06 7:07 
Questiongetting Server ip using vb.net Pin
GabrielVarun20-Sep-06 3:54
GabrielVarun20-Sep-06 3:54 
QuestionSQL Server Pin
Bravoone_200619-Sep-06 22:38
Bravoone_200619-Sep-06 22:38 
AnswerRe: SQL Server Pin
Colin Angus Mackay20-Sep-06 2:31
Colin Angus Mackay20-Sep-06 2:31 
QuestionI cannot retrive the field value Pin
vicky0000019-Sep-06 21:56
vicky0000019-Sep-06 21:56 
QuestionSql to Excel Pin
minniemooo19-Sep-06 21:31
minniemooo19-Sep-06 21:31 

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.