Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

ed5756

@ed5756
About
Posts
9
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I have fallen in disgrace, I am programming in VB.NET
    E ed5756

    Ah, I always enjoy another VB vs. C# discussion. As Woody Allen in one of his movies remembered his dad bickering with his mom, "OK! Have it it your way! The Atlantic Ocean is better than the Pacific!" As a programmer who cut his teeth on Fortran in the sixties, I have a number of languages under my belt, including the various dialects of C. My favorite was Pascal - now there was a readable language. I admit to having become a lazy man in my dotage. In these modern times I gravitate to VB.NET. My.Computer sure is handy! Yes, I run into incredulity and condescension from the young professional IT types (whippersnappers!), but the fact is the results are the same with either language and are not improved by curly brackets, no matter how many.

    Ed Greenawald

    The Lounge csharp

  • sql noob question on COUNT
    E ed5756

    Sorry, there was a typo in my last post. That query should have read

    select userid,username,max(ct) as Over20
    from
    (Select userid,username,count(*) as ct from temptable as a where userid=1 and score>20 group by userid, username union Select top 1 userid,username,0 as ct from temptable as b where userid=1) group by userid,username

    I have run the 2-step solution using a view on SQL Server and it works.

    Database question database help

  • sql noob question on COUNT
    E ed5756

    OK, you want to return a 0 if there are no scores over 20. That is trickier. This will return the count of Bob's scores over 20:

    Select userid,username,count(*) as [count] from temptable where userid=1 and score>20 group by userid

    This union query will return that same result and also a dummy record with a 0 count:

    Select userid,username,count(*) as ct from temptable as a where userid=1 and score>20 group by userid, username
    union
    Select top 1 userid,username,0 as ct from temptable as b where userid=1

    One would think then that using the MAX function in a sub-select would get your desired result:

    select userid,username,max(ct) as
    from
    (Select userid,username,count(*) as ct from temptable as a where userid=1 and score>20 group by userid, username
    union
    Select top 1 userid,username,0 as ct from temptable as b where userid=1)
    group by userid,username

    But I find that in T-SQL for some reason it throws an error. However, if I first define a view based on that union, then this works:

    select userid,username,max(ct) from view_c as Over20 group by userid, username

    Database question database help

  • sql noob question on COUNT
    E ed5756

    Try:

    select userid,username,count(*) from temptable where userid=1 and score>20 group by userid

    Database question database help

  • creating hyperlink in SQL Server2005
    E ed5756

    If you are still using the Access front-end, just pass the text as a parameter to the VBA FollowHyperlink function and it will open.

    Database database sql-server sysadmin help

  • Simple way to search for all special characters in all fields?
    E ed5756

    What you want to use is regular expressions. Plenty of examples on google, e.g. http://www.sqlteam.com/article/regular-expressions-in-t-sql[^]

    Database database question discussion

  • Reset auto number in Access
    E ed5756

    Rather than beat up the poor questioner for asking, I'll just trust that he has his reasons and offer the suggestion that he use tools/database/compact and repair after deleting the records. This will cause the next autonumber to proceed in sequence. In general you should not do this for all the reasons others have supplied. But I have been known to do it myself when cleaning out test data before deployment.

    Database database com

  • Do no evil, but sod the staff
    E ed5756

    Yer all young punks! I was coding in Algol and Fortran way back in 1964 when the internet was not yet a gleam in Al Gore's eye and "loosing" was still spelled "losing."

    The Lounge php com tools question announcement

  • Bob - lonely no more
    E ed5756

    Like the face of Jesus in the tortilla, this "woman" is yet another manifestation of the brain's uncanny ability to interpret random signals as familiar forms. Newborns come already wired to recognize faces. Technical stock analysts think they see clear buy and sell signals in stock market noise. Uncle_Ed

    The Lounge html com announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups