Jump to content

I need the SUM of 2 queries than ordered


XpertWorlock

Recommended Posts

Hey guys, I have a SQL query that goes like this

 

SELECT page

FROM keywords

WHERE keyword_id =  '17'

UNION SELECT page

FROM keywords

WHERE keyword_id =  '36'

ORDER BY weight DESC

 

 

SQL TABLE goes as this

 

 

   

keyword_id

   

page

   

weight

 

 

   

17

   

example.php

   

20

 

 

   

36

   

example.php

   

80

 

 

   

17

   

test.php

   

5

 

 

   

36

   

test.php

   

10

 

 

 

So for this example, I need the results to return the "example.php" row first.

I need it to add the 2 weights together (100,15) by page

 

So the outcome would be :

 

example.php

test.php

 

 

Any help guys  :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.