How can I achieve this using SQL ?

mrchonginhk

Well-known Member
Joined
Dec 3, 2004
Messages
679
I have a mdb table like this

Name Date Duration
========================
Paul 25-Jul-08 PM
John 26-Jul-08 Full Day

How can I turn it into this using SQL?

Name 25-Jul-08 26-Jul-08
=====================
Paul PM
John Full Day


Pls help. Thanks.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

This is how I'd do it in Excel. I assume Access is similar. HTH, Fazza

Code:
TRANSFORM MAX(Duration)
SELECT Name
FROM tblData
GROUP BY Name
PIVOT Date
 
Upvote 0
Glad it works.

Well, MAX is just a function to get the text into the cross tab.

I must stress I am not an Access user. This is just what I do in Excel for the same thing. The cross tab requires a function. Typically this might be a SUM. Or maybe AVERAGE or MAX or MIN or whatever. This works fine when you have numbers to add or average or whatever. As soon as the data is text, the SUM will 'bomb out'. So when I encountered text and wanted a cross tab result - and this was a couple of years ago, I think I've posted this in the Excel section some time ago - I tried the MAX function to see what would happen, and it worked. It was just an acceptable function in the cross tab that worked with text.

Regards, Fazza
 
Upvote 0
Glad it works.

Well, MAX is just a function to get the text into the cross tab.

I must stress I am not an Access user. This is just what I do in Excel for the same thing. The cross tab requires a function. Typically this might be a SUM. Or maybe AVERAGE or MAX or MIN or whatever. This works fine when you have numbers to add or average or whatever. As soon as the data is text, the SUM will 'bomb out'. So when I encountered text and wanted a cross tab result - and this was a couple of years ago, I think I've posted this in the Excel section some time ago - I tried the MAX function to see what would happen, and it worked. It was just an acceptable function in the cross tab that worked with text.

Regards, Fazza

That's fascinating (and useful!) Fazza (y)
 
Upvote 0
Thanks for the feedback, Richard.

I'll see if I can find an old Excel post where I might have done the same thing. (y)
 
Upvote 0

Forum statistics

Threads
1,215,972
Messages
6,127,997
Members
449,414
Latest member
sameri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top