Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: SQL


Message #1 by David Taylor <DTAYLOR@d...> on Fri, 24 Nov 2000 11:23:30 -0000
hi

replace the column names with appropriate names for your table

select
    count(*) as thecount,
    ltrim(right(imagename,len(imagename)-charindex('.',imagename,0))) as 
extn
    from
        imagestable
            group by
                imagename
                        order by
                        imagename




jigs
  ----- Original Message -----
  From: David Taylor
  To: sql language
  Sent: Friday, November 24, 2000 4:53 PM
  Subject: [sql_language] SQL


  I have a table containing image names and I wanted to return a record 
with
  each field containing a total of each image type: jpeg, gif, etc.  The
  following is the best I could come up with, but it seems very 
inefficient;
  is there a simpler/better way?

  SELECT *
  FROM countGif CROSS JOIN countJpeg

  CREATE VIEW dbo.countJpeg
  AS
  SELECT COUNT(*) AS jpeg
  FROM log WHERE target LIKE '%.jpeg'

  CREATE VIEW dbo.countGif
  AS
  SELECT COUNT(*) AS gif
  FROM log WHERE target LIKE '%.gif'

  Results:

    gif        jpeg
   9134     2345




  Return to Index