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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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 :beerchug:
 
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. :beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,445
Messages
6,172,177
Members
452,446
Latest member
walkman99

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