Re: extreme help with query of 2 tables into 1 long table



On Tue, 7 Jun 2005 10:26:02 -0700, BIGLU wrote:

(snip)
>IF YOU HAVE A BETTER WAY TO GET ALL THE INFORMATION ANY SUGGESTIONS WOULD BE
>GREAT!

Hi BIGLU,

First: The format you used to describe your data makes it very hard to
read and understand and almost impossible to reproduce. For future
postings, please include CREATE TABLE and INSERT statements for table
structure and sample data, as described here: www.aspfaq.com/5006.

Second: What you're trying to achieve looks like a pivot, or cross-tab
query. The front end/presentation layer is actually the best place for
that task. If you have to do it on the server, then try if you can adapt
the following to your needs:

SELECT u.UserID,
MAX(CASE WHEN d.DetailCD = 'awdM0' THEN d.detailValue END) AS
awdM0,
MAX(CASE WHEN d.DetailCD = 'awdD0' THEN d.detailValue END) AS
awdD0,
.....
FROM Users AS u
INNER JOIN UserDetails AS d
ON d.UserID = u.UserID
GROUP BY u.UserID


Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
.



Relevant Pages

  • Re: Splitting and comparing file names
    ... with the general format would really be much preferred... ... sample data would be nice. ... You have a case of premature declaration. ...
    (perl.beginners)
  • Re: hash key not found .. WHY NOT?
    ... filea.csv format: ... Where file1.csv is using BK=AK to lookup A3 and A4. ... Not a word of this makes sense nor matches your sample data. ... Please show REAL sample input and REAL sample output. ...
    (perl.beginners)
  • Size limits on IWMWriter::WriteSample ?
    ... building a profile from the stream information from the codec that mostly ... I'm using the "20kbps, 22Khz, Mono CBR" codec format. ... that is missing the end of the sample data. ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Conditional Format
    ... Assuming the sample data: ... Let's split the data first ... Select "MDY" from the drop menu under "Col data format" ... Click Format button> Patterns tab> Light blue? ...
    (microsoft.public.excel.newusers)
  • Re: a sql query that doesnt return any record (performing date comparison)
    ... Name: Table1 ... Congratulations on using ISO format. ... Considering that JET stores datetime data as 8 bytes that are roughly ...
    (comp.databases.ms-access)