Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
alpazar
Starting Member
2 Posts |
Posted - 2014-06-05 : 09:46:53
|
Hi,I am trying to select all the data which are not associated with values older than a specific value.. For example:i have:paola -- 2paola -- 3paola -- 10jessica -- 3jessica -- 12james -- 3james -- 2james -- 5I want to query only those names, that are associated with numbers greater than 3. So, for this example, the result would be only Jessica. the others should be discarded.Please can you help me with this query?Thank you in advance!Alpazar |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-06-05 : 11:58:36
|
Here is a template:SELCET <ColumnName1>FROM <TableName>WHERE <ColumnName2> > <value> |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-06-06 : 08:37:18
|
[code]SELECT *FROM(SELECT *,SUM(CASE WHEN Column2 < 3 THEN 1 ELSE 0 END) OVER (PARTITION BY Column1) AS OccFROM Table)tWHERE Occ = 0[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
alpazar
Starting Member
2 Posts |
Posted - 2014-06-06 : 11:15:45
|
thnx for your replies..but nothing of them works...:( |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-06-06 : 11:55:06
|
Missed the part about all the numbers being grater than 3. Not tested, but you need to check against the MIN:SELECT NameFROM TableGROUP BY NameHAVING MIN(NumberColumn) > 3 |
|
|
|
|
|