View previous topic :: View next topic
|
Author |
Message |
shri_shant
New User
Joined: 26 Oct 2005 Posts: 16
|
|
|
|
I am having table(p) as follows and output given in table below that what is query to get that output.........?
p# pname color weight city
p1 Nut red 12 london
p2 Bolt green 17 paris
p3 Screw Blue 17 Rome
p4 Screw red 14 London
p5 Cam blue 12 paris
p6 Cog red 19 London
Output table is
weight pname
12 cam
nut
14 screw
17 bolt
screw
19 cog
Thanks in advance |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Code: |
SELECT PNAME, WEIGHT FROM <TABLE-NAME> WHERE 1 = 1
GROUP BY PNAME, WEIGHT HAVING COUNT(WEIGHT)>1; |
Try this & let me know the results....
Regards,
Priyesh. |
|
Back to top |
|
|
akashs
New User
Joined: 24 Nov 2005 Posts: 49 Location: chennai
|
|
|
|
priyesh ,
iam unable to understand ur query ...wht is 1=1.expalin it plz...
regards,
akash |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
wht is 1=1.expalin it plz... |
It means always...
Regards,
Priyesh. |
|
Back to top |
|
|
reachsenthilnathan
New User
Joined: 20 Nov 2005 Posts: 15
|
|
|
|
1=1 Is always true. It is required as you need to put a where condition in the query which has group by and having.
Please correct me if i am wrong.
With Regards,
Senthil Nathan.R |
|
Back to top |
|
|
|